Merge branch 'develop-3.0' of ssh://192.168.1.29/rk/kernel into develop-3.0
authorJacobChen <cc@rock-chips.com>
Thu, 24 Nov 2011 12:05:13 +0000 (20:05 +0800)
committerJacobChen <cc@rock-chips.com>
Thu, 24 Nov 2011 12:05:13 +0000 (20:05 +0800)
130 files changed:
arch/arm/configs/rk29_ddr3sdk_defconfig
arch/arm/configs/rk29_k97_defconfig
arch/arm/configs/rk29_phonesdk_defconfig
arch/arm/configs/rk29_td8801_v2_defconfig [new file with mode: 0644]
arch/arm/mach-rk29/Kconfig
arch/arm/mach-rk29/Makefile
arch/arm/mach-rk29/board-rk29-ddr3sdk.c
arch/arm/mach-rk29/board-rk29-k97.c
arch/arm/mach-rk29/board-rk29-phonesdk.c
arch/arm/mach-rk29/board-rk29-td8801_v2-key.c [new file with mode: 0644]
arch/arm/mach-rk29/board-rk29-td8801_v2-rfkill.c [new file with mode: 0644]
arch/arm/mach-rk29/board-rk29-td8801_v2.c [new file with mode: 0755]
arch/arm/mach-rk29/ddr.c
arch/arm/mach-rk29/devices.c
arch/arm/mach-rk29/devices.h
arch/arm/mach-rk29/include/mach/board.h
arch/arm/mach-rk29/pm.c
arch/arm/mach-rk29/spi_sram.c
drivers/cmmb/cmmb_class.h
drivers/cmmb/cmmb_memory.c
drivers/cmmb/siano/smscoreapi.c
drivers/cmmb/siano/smsspiphy.h
drivers/headset_observe/rk_headset.c
drivers/input/gsensor/Kconfig
drivers/input/gsensor/Makefile
drivers/input/gsensor/bma023.c [new file with mode: 0644]
drivers/input/misc/Kconfig
drivers/input/misc/Makefile
drivers/input/misc/al3006.c [new file with mode: 0644]
drivers/input/misc/al3006.h [new file with mode: 0644]
drivers/input/touchscreen/Kconfig
drivers/input/touchscreen/Makefile
drivers/input/touchscreen/eeti_egalax_i2c.c
drivers/input/touchscreen/gt818_ts.c
drivers/input/touchscreen/ili2102_ts.c
drivers/input/touchscreen/pixcir_i2c_ts.c [new file with mode: 0644]
drivers/input/touchscreen/pixcir_i2c_ts.h [new file with mode: 0644]
drivers/media/video/gc0309.c
drivers/mfd/wm831x-i2c.c
drivers/mfd/wm8994-core.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/mtk23d.c
drivers/misc/sc8800.c [new file with mode: 0755]
drivers/misc/tdsc8800.c [new file with mode: 0755]
drivers/net/wireless/Kconfig
drivers/net/wireless/bcm4319/ChangeLog.txt [deleted file]
drivers/net/wireless/bcm4319/Kconfig [deleted file]
drivers/net/wireless/bcm4319/Kconfig.bcm4319 [deleted file]
drivers/net/wireless/bcm4319/Makefile
drivers/net/wireless/bcm4319/Makefile.bcm4319 [deleted file]
drivers/net/wireless/bcm4319/bcmpcispi.c
drivers/net/wireless/bcm4319/bcmsdh_linux.c
drivers/net/wireless/bcm4319/bcmsdh_sdmmc.c
drivers/net/wireless/bcm4319/bcmsdh_sdmmc_linux.c
drivers/net/wireless/bcm4319/bcmsdstd.c
drivers/net/wireless/bcm4319/bcmsdstd_linux.c
drivers/net/wireless/bcm4319/bcmspibrcm.c [new file with mode: 0644]
drivers/net/wireless/bcm4319/dhd.h
drivers/net/wireless/bcm4319/dhd_bus.h
drivers/net/wireless/bcm4319/dhd_cdc.c
drivers/net/wireless/bcm4319/dhd_common.c
drivers/net/wireless/bcm4319/dhd_custom_gpio.c
drivers/net/wireless/bcm4319/dhd_dbg.h
drivers/net/wireless/bcm4319/dhd_linux.c
drivers/net/wireless/bcm4319/dhd_proto.h
drivers/net/wireless/bcm4319/dhd_sdio.c
drivers/net/wireless/bcm4319/firmware/nvram_4319_201008.txt [deleted file]
drivers/net/wireless/bcm4319/include/bcmdefs.h
drivers/net/wireless/bcm4319/include/bcmsdh_sdmmc.h
drivers/net/wireless/bcm4319/include/bcmspibrcm.h [new file with mode: 0644]
drivers/net/wireless/bcm4319/include/epivers.h
drivers/net/wireless/bcm4319/include/linuxver.h
drivers/net/wireless/bcm4319/include/proto/bcmevent.h
drivers/net/wireless/bcm4319/include/sbchipc.h
drivers/net/wireless/bcm4319/include/spid.h [new file with mode: 0644]
drivers/net/wireless/bcm4319/include/wifi_version.h [new file with mode: 0644]
drivers/net/wireless/bcm4319/include/wlioctl.h
drivers/net/wireless/bcm4319/linux_osl.c
drivers/net/wireless/bcm4319/mkclean.sh [deleted file]
drivers/net/wireless/bcm4319/mkpkg.sh [deleted file]
drivers/net/wireless/bcm4319/wl_cfg80211.c
drivers/net/wireless/bcm4319/wl_iw.c
drivers/net/wireless/bcm4319/wl_iw.h
drivers/net/wireless/bcm4319/wl_iw_dbg.c [deleted file]
drivers/net/wireless/rtl8192c/Kconfig
drivers/net/wireless/rtl8192c/core/rtw_ioctl_set.uu
drivers/net/wireless/rtl8192c/core/rtw_mlme_ext.c
drivers/net/wireless/rtl8192c/include/autoconf.h
drivers/net/wireless/rtl8192c/include/osdep_service.h
drivers/net/wireless/rtl8192c/include/rtw_io.h
drivers/net/wireless/rtl8192c/os_dep/linux/ioctl_linux.uu
drivers/net/wireless/rtl8192c/os_dep/linux/usb_intf.c [changed mode: 0755->0644]
drivers/net/wireless/rtl8192c/os_dep/linux/wifi_power.c
drivers/net/wireless/rtl8192c/os_dep/linux/wifi_version.h
drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h [changed mode: 0755->0644]
drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h [changed mode: 0755->0644]
drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c [changed mode: 0755->0644]
drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c [changed mode: 0755->0644]
drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c [changed mode: 0755->0644]
drivers/usb/core/hub.c
drivers/usb/dwc_otg/dwc_otg_cil.c
drivers/usb/dwc_otg/dwc_otg_hcd_intr.c
drivers/video/backlight/rk29_buttonlight.c
drivers/video/display/screen/Kconfig
drivers/video/display/screen/Makefile
drivers/video/display/screen/lcd_ls035y8dx04a.c [new file with mode: 0644]
drivers/video/hdmi/hdmi-codec.c
include/linux/mfd/wm8994/core.h
include/linux/mfd/wm8994/pdata.h
include/linux/mtk23d.h
kernel/power/earlysuspend.c
pack-kernel.sh
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/alc5621.c [deleted file]
sound/soc/codecs/alc5621.h [deleted file]
sound/soc/codecs/rt5621.c [new file with mode: 0644]
sound/soc/codecs/rt5621.h [new file with mode: 0644]
sound/soc/codecs/rt5631.c
sound/soc/codecs/wm8988.c
sound/soc/codecs/wm8994.c
sound/soc/rk29/Kconfig
sound/soc/rk29/Makefile
sound/soc/rk29/rk29_alc5621.c [deleted file]
sound/soc/rk29/rk29_pcm.c
sound/soc/rk29/rk29_rt5621.c [new file with mode: 0644]
sound/soc/rk29/rk29_wm8988.c
sound/soc/rk29/rk29_wm8994.c

index ebe4cb2139f44255181727d239e988a00d4e3ee8..15763db14f9f0214f825aa7bba7feda7902c9f98 100755 (executable)
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.32.27
-# Thu Sep 15 19:19:01 2011
-#
-CONFIG_ARM=y
-CONFIG_SYS_SUPPORTS_APM_EMULATION=y
-CONFIG_HAVE_SCHED_CLOCK=y
-CONFIG_GENERIC_GPIO=y
-CONFIG_GENERIC_TIME=y
-CONFIG_GENERIC_CLOCKEVENTS=y
-CONFIG_GENERIC_HARDIRQS=y
-CONFIG_STACKTRACE_SUPPORT=y
-CONFIG_HAVE_LATENCYTOP_SUPPORT=y
-CONFIG_LOCKDEP_SUPPORT=y
-CONFIG_TRACE_IRQFLAGS_SUPPORT=y
-CONFIG_HARDIRQS_SW_RESEND=y
-CONFIG_GENERIC_IRQ_PROBE=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_ARCH_HAS_CPUFREQ=y
-CONFIG_GENERIC_HWEIGHT=y
-CONFIG_GENERIC_CALIBRATE_DELAY=y
-CONFIG_ZONE_DMA=y
-CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
-CONFIG_VECTORS_BASE=0xffff0000
-CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
-CONFIG_CONSTRUCTORS=y
-
-#
-# General setup
-#
 CONFIG_EXPERIMENTAL=y
-CONFIG_BROKEN_ON_SMP=y
-CONFIG_LOCK_KERNEL=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-CONFIG_LOCALVERSION=""
 # CONFIG_LOCALVERSION_AUTO is not set
-CONFIG_HAVE_KERNEL_GZIP=y
-CONFIG_HAVE_KERNEL_LZO=y
-# CONFIG_KERNEL_GZIP is not set
-# CONFIG_KERNEL_BZIP2 is not set
-# CONFIG_KERNEL_LZMA is not set
-CONFIG_KERNEL_LZO=y
 # CONFIG_SWAP is not set
-# CONFIG_SYSVIPC is not set
-# CONFIG_POSIX_MQUEUE is not set
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_TASKSTATS is not set
-# CONFIG_AUDIT is not set
-
-#
-# RCU Subsystem
-#
-CONFIG_TREE_RCU=y
-# CONFIG_TREE_PREEMPT_RCU is not set
-# CONFIG_RCU_TRACE is not set
-CONFIG_RCU_FANOUT=32
-# CONFIG_RCU_FANOUT_EXACT is not set
-# CONFIG_TREE_RCU_TRACE is not set
-# CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=19
 CONFIG_CGROUPS=y
 CONFIG_CGROUP_DEBUG=y
-# CONFIG_CGROUP_NS is not set
 CONFIG_CGROUP_FREEZER=y
-# CONFIG_CGROUP_DEVICE is not set
-# CONFIG_CPUSETS is not set
 CONFIG_CGROUP_CPUACCT=y
 CONFIG_RESOURCE_COUNTERS=y
-# CONFIG_CGROUP_MEM_RES_CTLR is not set
 CONFIG_CGROUP_SCHED=y
-CONFIG_FAIR_GROUP_SCHED=y
 CONFIG_RT_GROUP_SCHED=y
-# CONFIG_SYSFS_DEPRECATED_V2 is not set
-# CONFIG_RELAY is not set
-# CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_INITRAMFS_SOURCE=""
-CONFIG_RD_GZIP=y
-# CONFIG_RD_BZIP2 is not set
-# CONFIG_RD_LZMA is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SYSCTL=y
-CONFIG_ANON_INODES=y
 CONFIG_PANIC_TIMEOUT=5
-CONFIG_EMBEDDED=y
-CONFIG_UID16=y
 # CONFIG_SYSCTL_SYSCALL is not set
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_HOTPLUG=y
-CONFIG_PRINTK=y
-CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
-CONFIG_BASE_FULL=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_SIGNALFD=y
-CONFIG_TIMERFD=y
-CONFIG_EVENTFD=y
-CONFIG_SHMEM=y
 CONFIG_ASHMEM=y
-CONFIG_AIO=y
-
-#
-# Kernel Performance Events And Counters
-#
-CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_COMPAT_BRK=y
+CONFIG_EMBEDDED=y
 CONFIG_SLAB=y
-# CONFIG_SLUB is not set
-# CONFIG_SLOB is not set
-# CONFIG_PROFILING is not set
-CONFIG_HAVE_OPROFILE=y
-# CONFIG_KPROBES is not set
-CONFIG_HAVE_KPROBES=y
-CONFIG_HAVE_KRETPROBES=y
-CONFIG_HAVE_CLK=y
-
-#
-# GCOV-based kernel profiling
-#
-# CONFIG_SLOW_WORK is not set
-CONFIG_HAVE_GENERIC_DMA_COHERENT=y
-CONFIG_SLABINFO=y
-CONFIG_RT_MUTEXES=y
-CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
-# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_BLOCK=y
 # CONFIG_LBDAF is not set
 # CONFIG_BLK_DEV_BSG is not set
-# CONFIG_BLK_DEV_INTEGRITY is not set
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-# CONFIG_IOSCHED_AS is not set
 # CONFIG_IOSCHED_DEADLINE is not set
-CONFIG_IOSCHED_CFQ=y
-# CONFIG_DEFAULT_AS is not set
-# CONFIG_DEFAULT_DEADLINE is not set
-CONFIG_DEFAULT_CFQ=y
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_FREEZER=y
-
-#
-# System Type
-#
-CONFIG_MMU=y
-# CONFIG_ARCH_AAEC2000 is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_REALVIEW is not set
-# CONFIG_ARCH_VERSATILE is not set
-# CONFIG_ARCH_AT91 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_GEMINI is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_EP93XX is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_MXC is not set
-# CONFIG_ARCH_STMP3XXX is not set
-# CONFIG_ARCH_NETX is not set
-# CONFIG_ARCH_H720X is not set
-# CONFIG_ARCH_NOMADIK is not set
-# CONFIG_ARCH_IOP13XX is not set
-# CONFIG_ARCH_IOP32X is not set
-# CONFIG_ARCH_IOP33X is not set
-# CONFIG_ARCH_IXP23XX is not set
-# CONFIG_ARCH_IXP2000 is not set
-# CONFIG_ARCH_IXP4XX is not set
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_KIRKWOOD is not set
-# CONFIG_ARCH_LOKI is not set
-# CONFIG_ARCH_MV78XX0 is not set
-# CONFIG_ARCH_ORION5X is not set
-# CONFIG_ARCH_MMP is not set
-# CONFIG_ARCH_KS8695 is not set
-# CONFIG_ARCH_NS9XXX is not set
-# CONFIG_ARCH_W90X900 is not set
-# CONFIG_ARCH_PNX4008 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_MSM is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_S3C2410 is not set
-# CONFIG_ARCH_S3C64XX is not set
-# CONFIG_ARCH_S5PC1XX is not set
-# CONFIG_ARCH_SHARK is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_U300 is not set
-# CONFIG_ARCH_DAVINCI is not set
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_BCMRING is not set
 CONFIG_ARCH_RK29=y
-# CONFIG_MACH_RK29SDK is not set
 CONFIG_MACH_RK29SDK_DDR3=y
-# CONFIG_MACH_RK29WINACCORD is not set
-# CONFIG_MACH_RK29FIH is not set
-# CONFIG_MACH_RK29_MALATA is not set
-# CONFIG_MACH_RK29_PHONESDK is not set
-# CONFIG_MACH_RK29_A22 is not set
-# CONFIG_MACH_RK29_PHONEPADSDK is not set
-# CONFIG_MACH_RK29_newton is not set
-# CONFIG_MACH_RK29_P91 is not set
-# CONFIG_DDR_TYPE_DDRII is not set
-# CONFIG_DDR_TYPE_LPDDR is not set
-# CONFIG_DDR_TYPE_DDR3_800D is not set
-# CONFIG_DDR_TYPE_DDR3_800E is not set
-# CONFIG_DDR_TYPE_DDR3_1066E is not set
-# CONFIG_DDR_TYPE_DDR3_1066F is not set
-# CONFIG_DDR_TYPE_DDR3_1066G is not set
-# CONFIG_DDR_TYPE_DDR3_1333F is not set
-# CONFIG_DDR_TYPE_DDR3_1333G is not set
-# CONFIG_DDR_TYPE_DDR3_1333H is not set
-# CONFIG_DDR_TYPE_DDR3_1333J is not set
-# CONFIG_DDR_TYPE_DDR3_1600G is not set
-# CONFIG_DDR_TYPE_DDR3_1600H is not set
-# CONFIG_DDR_TYPE_DDR3_1600J is not set
-# CONFIG_DDR_TYPE_DDR3_1600K is not set
-# CONFIG_DDR_TYPE_DDR3_1866J is not set
-# CONFIG_DDR_TYPE_DDR3_1866K is not set
-# CONFIG_DDR_TYPE_DDR3_1866L is not set
-# CONFIG_DDR_TYPE_DDR3_1866M is not set
-# CONFIG_DDR_TYPE_DDR3_2133K is not set
-# CONFIG_DDR_TYPE_DDR3_2133L is not set
-# CONFIG_DDR_TYPE_DDR3_2133M is not set
-# CONFIG_DDR_TYPE_DDR3_2133N is not set
-CONFIG_DDR_TYPE_DDR3_DEFAULT=y
-CONFIG_RK29_MEM_SIZE_M=512
 CONFIG_DDR_SDRAM_FREQ=456
-CONFIG_DDR_FREQ=y
-# CONFIG_DDR_RECONFIG is not set
 CONFIG_WIFI_CONTROL_FUNC=y
-
-#
-# RK29 VPU (Video Processing Unit) support
-#
-CONFIG_RK29_VPU=y
-CONFIG_RK29_VPU_SERVICE=y
-# CONFIG_RK29_VPU_DEBUG is not set
 CONFIG_RK29_JTAG=y
-CONFIG_RK29_LAST_LOG=y
-
-#
-# support for RK29 power manage 
-#
-# CONFIG_RK29_WORKING_POWER_MANAGEMENT is not set
-# CONFIG_RK29_CLK_SWITCH_TO_32K is not set
-# CONFIG_RK29_GPIO_SUSPEND is not set
-CONFIG_RK29_PWM_INSRAM=y
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_32v6K=y
-CONFIG_CPU_V7=y
-CONFIG_CPU_32v7=y
-CONFIG_CPU_ABRT_EV7=y
-CONFIG_CPU_PABRT_V7=y
-CONFIG_CPU_CACHE_V7=y
-CONFIG_CPU_CACHE_VIPT=y
-CONFIG_CPU_COPY_V6=y
-CONFIG_CPU_TLB_V7=y
-CONFIG_CPU_HAS_ASID=y
-CONFIG_CPU_CP15=y
-CONFIG_CPU_CP15_MMU=y
-
-#
-# Processor Features
-#
-CONFIG_ARM_THUMB=y
 CONFIG_ARM_THUMBEE=y
-# CONFIG_CPU_ICACHE_DISABLE is not set
-# CONFIG_CPU_DCACHE_DISABLE is not set
-# CONFIG_CPU_BPREDICT_DISABLE is not set
-CONFIG_HAS_TLS_REG=y
-CONFIG_ARM_L1_CACHE_SHIFT=6
-# CONFIG_ARM_ERRATA_430973 is not set
-# CONFIG_ARM_ERRATA_458693 is not set
-# CONFIG_ARM_ERRATA_460075 is not set
-CONFIG_ARM_GIC=y
-CONFIG_PL330=y
-CONFIG_COMMON_CLKDEV=y
-
-#
-# Bus support
-#
-# CONFIG_PCI_SYSCALL is not set
-# CONFIG_ARCH_SUPPORTS_MSI is not set
-# CONFIG_PCCARD is not set
-
-#
-# Kernel Features
-#
-CONFIG_TICK_ONESHOT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
-CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
-CONFIG_VMSPLIT_3G=y
-# CONFIG_VMSPLIT_2G is not set
-# CONFIG_VMSPLIT_1G is not set
-CONFIG_PAGE_OFFSET=0xC0000000
-# CONFIG_PREEMPT_NONE is not set
-# CONFIG_PREEMPT_VOLUNTARY is not set
 CONFIG_PREEMPT=y
-CONFIG_HZ=100
-# CONFIG_THUMB2_KERNEL is not set
 CONFIG_AEABI=y
 # CONFIG_OABI_COMPAT is not set
-# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
-# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
-CONFIG_HIGHMEM=y
-# CONFIG_HIGHPTE is not set
-CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
-CONFIG_PAGEFLAGS_EXTENDED=y
-CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_PHYS_ADDR_T_64BIT is not set
-CONFIG_ZONE_DMA_FLAG=1
-CONFIG_BOUNCE=y
-CONFIG_VIRT_TO_BUS=y
-CONFIG_HAVE_MLOCK=y
-CONFIG_HAVE_MLOCKED_PAGE_BIT=y
-# CONFIG_KSM is not set
 CONFIG_DEFAULT_MMAP_MIN_ADDR=32768
-CONFIG_ALIGNMENT_TRAP=y
-# CONFIG_UACCESS_WITH_MEMCPY is not set
-
-#
-# Boot options
-#
-CONFIG_ZBOOT_ROM_TEXT=0
-CONFIG_ZBOOT_ROM_BSS=0
-CONFIG_CMDLINE=""
-# CONFIG_XIP_KERNEL is not set
 CONFIG_KEXEC=y
-CONFIG_ATAGS_PROC=y
-
-#
-# CPU Power Management
-#
 CONFIG_CPU_FREQ=y
-CONFIG_CPU_FREQ_TABLE=y
-# CONFIG_CPU_FREQ_DEBUG is not set
-CONFIG_CPU_FREQ_STAT=y
 CONFIG_CPU_FREQ_STAT_DETAILS=y
-# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
-# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
-# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
-# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
-CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
-# CONFIG_CPU_IDLE is not set
-
-#
-# Floating point emulation
-#
-
-#
-# At least one emulation must be selected
-#
 CONFIG_VFP=y
-CONFIG_VFPv3=y
 CONFIG_NEON=y
-
-#
-# Userspace binary formats
-#
-CONFIG_BINFMT_ELF=y
-CONFIG_HAVE_AOUT=y
-# CONFIG_BINFMT_AOUT is not set
-# CONFIG_BINFMT_MISC is not set
-
-#
-# Power management options
-#
-CONFIG_PM=y
-# CONFIG_PM_DEBUG is not set
-CONFIG_PM_SLEEP=y
-CONFIG_SUSPEND=y
-CONFIG_SUSPEND_FREEZER=y
-CONFIG_HAS_WAKELOCK=y
-CONFIG_HAS_EARLYSUSPEND=y
 CONFIG_WAKELOCK=y
-CONFIG_WAKELOCK_STAT=y
-CONFIG_USER_WAKELOCK=y
-CONFIG_EARLYSUSPEND=y
-# CONFIG_NO_USER_SPACE_SCREEN_ACCESS_CONTROL is not set
-# CONFIG_CONSOLE_EARLYSUSPEND is not set
-CONFIG_FB_EARLYSUSPEND=y
-# CONFIG_APM_EMULATION is not set
-# CONFIG_PM_RUNTIME is not set
-CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_NET=y
-
-#
-# Networking options
-#
 CONFIG_PACKET=y
-# CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
-# CONFIG_XFRM_STATISTICS is not set
-# CONFIG_NET_KEY is not set
+CONFIG_NET_KEY=y
 CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_MULTIPLE_TABLES=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_IP_PNP_RARP=y
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_XFRM_TUNNEL is not set
-CONFIG_INET_TUNNEL=y
-CONFIG_INET_XFRM_MODE_TRANSPORT=y
-CONFIG_INET_XFRM_MODE_TUNNEL=y
-CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_ESP=y
+# CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_LRO is not set
-CONFIG_INET_DIAG=y
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_CUBIC=y
-CONFIG_DEFAULT_TCP_CONG="cubic"
-# CONFIG_TCP_MD5SIG is not set
 CONFIG_IPV6=y
-# CONFIG_IPV6_PRIVACY is not set
-# CONFIG_IPV6_ROUTER_PREF is not set
-# CONFIG_IPV6_OPTIMISTIC_DAD is not set
-# CONFIG_INET6_AH is not set
-# CONFIG_INET6_ESP is not set
-# CONFIG_INET6_IPCOMP is not set
-# CONFIG_IPV6_MIP6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
-CONFIG_INET6_XFRM_MODE_TRANSPORT=y
-CONFIG_INET6_XFRM_MODE_TUNNEL=y
-CONFIG_INET6_XFRM_MODE_BEET=y
-# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
-CONFIG_IPV6_SIT=y
-CONFIG_IPV6_NDISC_NODETYPE=y
-# CONFIG_IPV6_TUNNEL is not set
-# CONFIG_IPV6_MULTIPLE_TABLES is not set
-# CONFIG_IPV6_MROUTE is not set
-CONFIG_ANDROID_PARANOID_NETWORK=y
-# CONFIG_NETWORK_SECMARK is not set
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+CONFIG_IPV6_MIP6=y
+CONFIG_IPV6_TUNNEL=y
+CONFIG_IPV6_MULTIPLE_TABLES=y
 CONFIG_NETFILTER=y
 CONFIG_NETFILTER_DEBUG=y
-CONFIG_NETFILTER_ADVANCED=y
-
-#
-# Core Netfilter Configuration
-#
-CONFIG_NETFILTER_NETLINK=y
-CONFIG_NETFILTER_NETLINK_QUEUE=y
-CONFIG_NETFILTER_NETLINK_LOG=y
 CONFIG_NF_CONNTRACK=y
-CONFIG_NF_CT_ACCT=y
-CONFIG_NF_CONNTRACK_MARK=y
 CONFIG_NF_CONNTRACK_EVENTS=y
 CONFIG_NF_CT_PROTO_DCCP=y
-CONFIG_NF_CT_PROTO_GRE=y
 CONFIG_NF_CT_PROTO_SCTP=y
 CONFIG_NF_CT_PROTO_UDPLITE=y
 CONFIG_NF_CONNTRACK_AMANDA=y
@@ -498,442 +86,117 @@ CONFIG_NF_CONNTRACK_SANE=y
 CONFIG_NF_CONNTRACK_SIP=y
 CONFIG_NF_CONNTRACK_TFTP=y
 CONFIG_NF_CT_NETLINK=y
-CONFIG_NETFILTER_XTABLES=y
+CONFIG_NETFILTER_TPROXY=y
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y
 CONFIG_NETFILTER_XT_TARGET_CONNMARK=y
 CONFIG_NETFILTER_XT_TARGET_MARK=y
-# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
+CONFIG_NETFILTER_XT_TARGET_NFLOG=y
 CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y
-# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
-# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set
-# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set
+CONFIG_NETFILTER_XT_TARGET_TPROXY=y
+CONFIG_NETFILTER_XT_TARGET_TRACE=y
 CONFIG_NETFILTER_XT_MATCH_COMMENT=y
 CONFIG_NETFILTER_XT_MATCH_CONNBYTES=y
 CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=y
 CONFIG_NETFILTER_XT_MATCH_CONNMARK=y
 CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
-# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
-# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
-# CONFIG_NETFILTER_XT_MATCH_ESP is not set
 CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=y
 CONFIG_NETFILTER_XT_MATCH_HELPER=y
-CONFIG_NETFILTER_XT_MATCH_HL=y
-# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set
-# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
-# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set
-# CONFIG_NETFILTER_XT_MATCH_MAC is not set
-# CONFIG_NETFILTER_XT_MATCH_MARK is not set
-# CONFIG_NETFILTER_XT_MATCH_MULTIPORT is not set
-# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
-# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=y
+CONFIG_NETFILTER_XT_MATCH_LENGTH=y
+CONFIG_NETFILTER_XT_MATCH_LIMIT=y
+CONFIG_NETFILTER_XT_MATCH_MAC=y
+CONFIG_NETFILTER_XT_MATCH_MARK=y
+CONFIG_NETFILTER_XT_MATCH_POLICY=y
 CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y
+CONFIG_NETFILTER_XT_MATCH_QTAGUID=y
 CONFIG_NETFILTER_XT_MATCH_QUOTA=y
-# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
-# CONFIG_NETFILTER_XT_MATCH_REALM is not set
-# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
-# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
+CONFIG_NETFILTER_XT_MATCH_QUOTA2=y
+CONFIG_NETFILTER_XT_MATCH_QUOTA2_LOG=y
+CONFIG_NETFILTER_XT_MATCH_SOCKET=y
 CONFIG_NETFILTER_XT_MATCH_STATE=y
 CONFIG_NETFILTER_XT_MATCH_STATISTIC=y
 CONFIG_NETFILTER_XT_MATCH_STRING=y
-# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
 CONFIG_NETFILTER_XT_MATCH_TIME=y
 CONFIG_NETFILTER_XT_MATCH_U32=y
-# CONFIG_NETFILTER_XT_MATCH_OSF is not set
-# CONFIG_IP_VS is not set
-
-#
-# IP: Netfilter Configuration
-#
-CONFIG_NF_DEFRAG_IPV4=y
 CONFIG_NF_CONNTRACK_IPV4=y
-CONFIG_NF_CONNTRACK_PROC_COMPAT=y
-# CONFIG_IP_NF_QUEUE is not set
 CONFIG_IP_NF_IPTABLES=y
-CONFIG_IP_NF_MATCH_ADDRTYPE=y
 CONFIG_IP_NF_MATCH_AH=y
 CONFIG_IP_NF_MATCH_ECN=y
 CONFIG_IP_NF_MATCH_TTL=y
 CONFIG_IP_NF_FILTER=y
 CONFIG_IP_NF_TARGET_REJECT=y
+CONFIG_IP_NF_TARGET_REJECT_SKERR=y
 CONFIG_IP_NF_TARGET_LOG=y
-# CONFIG_IP_NF_TARGET_ULOG is not set
 CONFIG_NF_NAT=y
-CONFIG_NF_NAT_NEEDED=y
 CONFIG_IP_NF_TARGET_MASQUERADE=y
 CONFIG_IP_NF_TARGET_NETMAP=y
 CONFIG_IP_NF_TARGET_REDIRECT=y
-# CONFIG_NF_NAT_SNMP_BASIC is not set
-CONFIG_NF_NAT_PROTO_DCCP=y
-CONFIG_NF_NAT_PROTO_GRE=y
-CONFIG_NF_NAT_PROTO_UDPLITE=y
-CONFIG_NF_NAT_PROTO_SCTP=y
-CONFIG_NF_NAT_FTP=y
-CONFIG_NF_NAT_IRC=y
-CONFIG_NF_NAT_TFTP=y
-CONFIG_NF_NAT_AMANDA=y
-CONFIG_NF_NAT_PPTP=y
-CONFIG_NF_NAT_H323=y
-CONFIG_NF_NAT_SIP=y
-# CONFIG_IP_NF_MANGLE is not set
-# CONFIG_IP_NF_TARGET_TTL is not set
-# CONFIG_IP_NF_RAW is not set
+CONFIG_IP_NF_MANGLE=y
+CONFIG_IP_NF_RAW=y
 CONFIG_IP_NF_ARPTABLES=y
 CONFIG_IP_NF_ARPFILTER=y
 CONFIG_IP_NF_ARP_MANGLE=y
-
-#
-# IPv6: Netfilter Configuration
-#
-# CONFIG_NF_CONNTRACK_IPV6 is not set
-# CONFIG_IP6_NF_QUEUE is not set
-# CONFIG_IP6_NF_IPTABLES is not set
-# CONFIG_IP_DCCP is not set
-# CONFIG_IP_SCTP is not set
-# CONFIG_RDS is not set
-# CONFIG_TIPC is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_NET_DSA is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-# CONFIG_PHONET is not set
-# CONFIG_IEEE802154 is not set
-# CONFIG_NET_SCHED is not set
-# CONFIG_DCB is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_CAN is not set
-# CONFIG_IRDA is not set
+CONFIG_NF_CONNTRACK_IPV6=y
+CONFIG_IP6_NF_IPTABLES=y
+CONFIG_IP6_NF_TARGET_LOG=y
+CONFIG_IP6_NF_FILTER=y
+CONFIG_IP6_NF_TARGET_REJECT=y
+CONFIG_IP6_NF_TARGET_REJECT_SKERR=y
+CONFIG_IP6_NF_MANGLE=y
+CONFIG_IP6_NF_RAW=y
+CONFIG_BRIDGE=y
+# CONFIG_BRIDGE_IGMP_SNOOPING is not set
+CONFIG_PHONET=y
+CONFIG_NET_SCHED=y
+CONFIG_NET_SCH_HTB=y
+CONFIG_NET_SCH_INGRESS=y
+CONFIG_NET_CLS_U32=y
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_U32=y
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=y
+CONFIG_NET_ACT_GACT=y
+CONFIG_NET_ACT_MIRRED=y
 CONFIG_BT=y
 CONFIG_BT_L2CAP=y
 CONFIG_BT_SCO=y
 CONFIG_BT_RFCOMM=y
 CONFIG_BT_RFCOMM_TTY=y
-# CONFIG_BT_BNEP is not set
-# CONFIG_BT_HIDP is not set
-
-#
-# Bluetooth device drivers
-#
-# CONFIG_BT_HCIBTUSB is not set
-# CONFIG_BT_HCIBTSDIO is not set
+CONFIG_BT_BNEP=y
+CONFIG_BT_HIDP=y
 CONFIG_BT_HCIUART=y
 CONFIG_BT_HCIUART_H4=y
-# CONFIG_BT_HCIUART_BCSP is not set
-# CONFIG_BT_HCIUART_LL is not set
-# CONFIG_BT_HCIBCM203X is not set
-# CONFIG_BT_HCIBPA10X is not set
-# CONFIG_BT_HCIBFUSB is not set
-# CONFIG_BT_HCIVHCI is not set
-# CONFIG_BT_MRVL is not set
 CONFIG_BT_HCIBCM4325=y
-CONFIG_IDBLOCK=y
-# CONFIG_WIFI_MAC is not set
-# CONFIG_AF_RXRPC is not set
-CONFIG_WIRELESS=y
-# CONFIG_CFG80211 is not set
-CONFIG_CFG80211_DEFAULT_PS_VALUE=0
-# CONFIG_WIRELESS_OLD_REGULATORY is not set
-CONFIG_WIRELESS_EXT=y
-CONFIG_WIRELESS_EXT_SYSFS=y
-# CONFIG_LIB80211 is not set
-
-#
-# CFG80211 needs to be enabled for MAC80211
-#
-
-#
-# Some wireless drivers require a rate control algorithm
-#
-# CONFIG_WIMAX is not set
 CONFIG_RFKILL=y
 # CONFIG_RFKILL_PM is not set
-# CONFIG_RFKILL_INPUT is not set
-# CONFIG_NET_9P is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_UEVENT_HELPER_PATH=""
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
-CONFIG_STANDALONE=y
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-CONFIG_FW_LOADER=y
 # CONFIG_FIRMWARE_IN_KERNEL is not set
-CONFIG_EXTRA_FIRMWARE=""
-# CONFIG_DEBUG_DRIVER is not set
-# CONFIG_DEBUG_DEVRES is not set
-# CONFIG_SYS_HYPERVISOR is not set
-# CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_TESTS is not set
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
 CONFIG_MTD_CMDLINE_PARTS=y
-# CONFIG_MTD_AFS_PARTS is not set
-# CONFIG_MTD_AR7_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
 CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLKDEVS=y
 CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-# CONFIG_RFD_FTL is not set
-# CONFIG_SSFDC is not set
-# CONFIG_MTD_OOPS is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-# CONFIG_MTD_CFI is not set
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_MAP_BANK_WIDTH_1=y
-CONFIG_MTD_MAP_BANK_WIDTH_2=y
-CONFIG_MTD_MAP_BANK_WIDTH_4=y
-# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
-CONFIG_MTD_CFI_I1=y
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PLATRAM is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PHRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLOCK2MTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
 CONFIG_MTD_NAND_IDS=y
-# CONFIG_MTD_NAND is not set
 CONFIG_MTD_RKNAND=y
-CONFIG_MTD_NAND_RK29XX=y
-CONFIG_MTD_RKNAND_BUFFER=y
-# CONFIG_MTD_EMMC_CLK_POWER_SAVE is not set
-# CONFIG_MTD_NAND_RK29XX_DEBUG is not set
-# CONFIG_MTD_ONENAND is not set
-
-#
-# LPDDR flash memory drivers
-#
-# CONFIG_MTD_LPDDR is not set
-
-#
-# UBI - Unsorted block images
-#
-# CONFIG_MTD_UBI is not set
-# CONFIG_PARPORT is not set
-CONFIG_BLK_DEV=y
-# CONFIG_BLK_DEV_COW_COMMON is not set
 CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_UB is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_CDROM_PKTCDVD is not set
-# CONFIG_ATA_OVER_ETH is not set
-# CONFIG_MG_DISK is not set
 CONFIG_MISC_DEVICES=y
-CONFIG_ANDROID_PMEM=y
-# CONFIG_ICS932S401 is not set
-# CONFIG_ENCLOSURE_SERVICES is not set
-# CONFIG_KERNEL_DEBUGGER_CORE is not set
-# CONFIG_ISL29003 is not set
 CONFIG_UID_STAT=y
-# CONFIG_WL127X_RFKILL is not set
 CONFIG_APANIC=y
-CONFIG_APANIC_PLABEL="kpanic"
-# CONFIG_STE is not set
-# CONFIG_MTK23D is not set
-# CONFIG_FM580X is not set
-# CONFIG_MU509 is not set
-# CONFIG_RK29_NEWTON is not set
-# CONFIG_C2PORT is not set
-
-#
-# EEPROM support
-#
-# CONFIG_EEPROM_AT24 is not set
-# CONFIG_EEPROM_LEGACY is not set
-# CONFIG_EEPROM_MAX6875 is not set
-# CONFIG_EEPROM_93CX6 is not set
 CONFIG_RK29_SUPPORT_MODEM=y
-CONFIG_MODEM_ROCKCHIP_DEMO=y
-# CONFIG_MODEM_LONGCHEER_U6300V is not set
-# CONFIG_MODEM_THINKWILL_MW100G is not set
-# CONFIG_RK29_GPS is not set
-
-#
-# Motion Sensors Support
-#
-# CONFIG_MPU_NONE is not set
-# CONFIG_MPU_SENSORS_MPU3050 is not set
-# CONFIG_MPU_SENSORS_MPU6000 is not set
-# CONFIG_MPU_SENSORS_TIMERIRQ is not set
-CONFIG_HAVE_IDE=y
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_RAID_ATTRS is not set
 CONFIG_SCSI=y
-CONFIG_SCSI_DMA=y
-# CONFIG_SCSI_TGT is not set
-# CONFIG_SCSI_NETLINK is not set
-CONFIG_SCSI_PROC_FS=y
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
 CONFIG_BLK_DEV_SD=y
-# CONFIG_CHR_DEV_ST is not set
-# CONFIG_CHR_DEV_OSST is not set
-# CONFIG_BLK_DEV_SR is not set
-# CONFIG_CHR_DEV_SG is not set
-# CONFIG_CHR_DEV_SCH is not set
 CONFIG_SCSI_MULTI_LUN=y
-# CONFIG_SCSI_CONSTANTS is not set
-# CONFIG_SCSI_LOGGING is not set
-# CONFIG_SCSI_SCAN_ASYNC is not set
-CONFIG_SCSI_WAIT_SCAN=m
-
-#
-# SCSI Transports
-#
-# CONFIG_SCSI_SPI_ATTRS is not set
-# CONFIG_SCSI_FC_ATTRS is not set
-# CONFIG_SCSI_ISCSI_ATTRS is not set
-# CONFIG_SCSI_SAS_LIBSAS is not set
-# CONFIG_SCSI_SRP_ATTRS is not set
-CONFIG_SCSI_LOWLEVEL=y
-# CONFIG_ISCSI_TCP is not set
-# CONFIG_LIBFC is not set
-# CONFIG_LIBFCOE is not set
-# CONFIG_SCSI_DEBUG is not set
-# CONFIG_SCSI_DH is not set
-# CONFIG_SCSI_OSD_INITIATOR is not set
-# CONFIG_ATA is not set
 CONFIG_MD=y
-# CONFIG_BLK_DEV_MD is not set
 CONFIG_BLK_DEV_DM=y
-# CONFIG_DM_DEBUG is not set
 CONFIG_DM_CRYPT=y
-# CONFIG_DM_SNAPSHOT is not set
-# CONFIG_DM_MIRROR is not set
-# CONFIG_DM_ZERO is not set
-# CONFIG_DM_MULTIPATH is not set
-# CONFIG_DM_DELAY is not set
 CONFIG_DM_UEVENT=y
 CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_MACVLAN is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-# CONFIG_VETH is not set
-CONFIG_PHYLIB=y
-
-#
-# MII PHY device drivers
-#
-# CONFIG_MARVELL_PHY is not set
-# CONFIG_DAVICOM_PHY is not set
-# CONFIG_QSEMI_PHY is not set
-# CONFIG_LXT_PHY is not set
-# CONFIG_CICADA_PHY is not set
-# CONFIG_VITESSE_PHY is not set
-# CONFIG_SMSC_PHY is not set
-# CONFIG_BROADCOM_PHY is not set
-# CONFIG_ICPLUS_PHY is not set
-# CONFIG_REALTEK_PHY is not set
-# CONFIG_NATIONAL_PHY is not set
-# CONFIG_STE10XP is not set
-# CONFIG_LSI_ET1011C_PHY is not set
-# CONFIG_FIXED_PHY is not set
-# CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_AX88796 is not set
 CONFIG_RK29_VMAC=y
-# CONFIG_SMC91X is not set
-# CONFIG_DM9000 is not set
-# CONFIG_ETHOC is not set
-# CONFIG_SMC911X is not set
-# CONFIG_SMSC911X is not set
-# CONFIG_DNET is not set
-# CONFIG_IBM_NEW_EMAC_ZMII is not set
-# CONFIG_IBM_NEW_EMAC_RGMII is not set
-# CONFIG_IBM_NEW_EMAC_TAH is not set
-# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
-# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
-# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
-# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
-# CONFIG_B44 is not set
-# CONFIG_KS8842 is not set
-# CONFIG_KS8851_MLL is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
-CONFIG_WLAN=y
 CONFIG_WLAN_80211=y
-# CONFIG_WIFI_NONE is not set
 CONFIG_BCM4329=y
-# CONFIG_MV8686 is not set
-# CONFIG_BCM4319 is not set
-
-#
-# Enable WiMAX (Networking options) to see the WiMAX drivers
-#
-
-#
-# USB Network Adapters
-#
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET is not set
-# CONFIG_USB_HSO is not set
-# CONFIG_WAN is not set
 CONFIG_PPP=y
 CONFIG_PPP_MULTILINK=y
 CONFIG_PPP_FILTER=y
@@ -941,1344 +204,128 @@ CONFIG_PPP_ASYNC=y
 CONFIG_PPP_SYNC_TTY=y
 CONFIG_PPP_DEFLATE=y
 CONFIG_PPP_BSDCOMP=y
-# CONFIG_PPP_MPPE is not set
-# CONFIG_PPPOE is not set
-# CONFIG_PPPOL2TP is not set
-# CONFIG_PPPOLAC is not set
-# CONFIG_PPPOPNS is not set
-# CONFIG_SLIP is not set
-CONFIG_SLHC=y
-# CONFIG_NETCONSOLE is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-# CONFIG_ISDN is not set
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-# CONFIG_INPUT_FF_MEMLESS is not set
 CONFIG_INPUT_POLLDEV=y
-
-#
-# Userland interfaces
-#
 # CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_JOYDEV is not set
 CONFIG_INPUT_EVDEV=y
-# CONFIG_INPUT_EVBUG is not set
 CONFIG_INPUT_KEYRESET=y
-
-#
-# Input Device Drivers
-#
-CONFIG_INPUT_KEYBOARD=y
-CONFIG_KEYS_RK29=y
-# CONFIG_KEYS_RK29_NEWTON is not set
-# CONFIG_SYNAPTICS_SO340010 is not set
-# CONFIG_KEYBOARD_ADP5588 is not set
 # CONFIG_KEYBOARD_ATKBD is not set
-# CONFIG_QT2160 is not set
-# CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_GPIO is not set
-# CONFIG_KEYBOARD_WM831X_GPIO is not set
-# CONFIG_KEYBOARD_MATRIX is not set
-# CONFIG_KEYBOARD_MAX7359 is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_KEYBOARD_OPENCORES is not set
-# CONFIG_KEYBOARD_STOWAWAY is not set
-# CONFIG_KEYBOARD_SUNKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
 # CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TABLET is not set
 CONFIG_INPUT_TOUCHSCREEN=y
-# CONFIG_TOUCHSCREEN_ILI2102_IIC is not set
-# CONFIG_TOUCHSCREEN_IT7250 is not set
-# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
-# CONFIG_TOUCHSCREEN_AD7879 is not set
-# CONFIG_TOUCHSCREEN_EETI is not set
-# CONFIG_TOUCHSCREEN_FUJITSU is not set
-# CONFIG_TOUCHSCREEN_GUNZE is not set
-# CONFIG_TOUCHSCREEN_ELO is not set
-# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
-# CONFIG_TOUCHSCREEN_MCS5000 is not set
-# CONFIG_TOUCHSCREEN_MTOUCH is not set
-# CONFIG_TOUCHSCREEN_INEXIO is not set
-# CONFIG_TOUCHSCREEN_MK712 is not set
-# CONFIG_TOUCHSCREEN_PENMOUNT is not set
-# CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI is not set
-# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
-# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
-# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
-# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
-# CONFIG_TOUCHSCREEN_TSC2007 is not set
-# CONFIG_TOUCHSCREEN_W90X900 is not set
-# CONFIG_HANNSTAR_P1003 is not set
-# CONFIG_ATMEL_MXT224 is not set
-# CONFIG_SINTEK_3FA16 is not set
 CONFIG_EETI_EGALAX=y
 CONFIG_EETI_EGALAX_MAX_X=1087
 CONFIG_EETI_EGALAX_MAX_Y=800
-# CONFIG_EETI_EGALAX_DEBUG is not set
-# CONFIG_TOUCHSCREEN_IT7260 is not set
-# CONFIG_TOUCHSCREEN_IT7260_I2C is not set
-# CONFIG_TOUCHSCREEN_NAS is not set
-# CONFIG_LAIBAO_TS is not set
-# CONFIG_TOUCHSCREEN_GT801_IIC is not set
-# CONFIG_TOUCHSCREEN_GT818_IIC is not set
-# CONFIG_D70_L3188A is not set
-# CONFIG_TOUCHSCREEN_GT819 is not set
-# CONFIG_TOUCHSCREEN_FT5406 is not set
-# CONFIG_ATMEL_MXT1386 is not set
 CONFIG_INPUT_MISC=y
-# CONFIG_INPUT_LPSENSOR_ISL29028 is not set
-# CONFIG_INPUT_LPSENSOR_CM3602 is not set
-# CONFIG_INPUT_ATI_REMOTE is not set
-# CONFIG_INPUT_ATI_REMOTE2 is not set
-# CONFIG_INPUT_KEYCHORD is not set
-# CONFIG_INPUT_KEYSPAN_REMOTE is not set
-# CONFIG_INPUT_POWERMATE is not set
-# CONFIG_INPUT_YEALINK is not set
-# CONFIG_INPUT_CM109 is not set
 CONFIG_INPUT_UINPUT=y
-# CONFIG_INPUT_GPIO is not set
-# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
-# CONFIG_MAG_SENSORS is not set
 CONFIG_G_SENSOR_DEVICE=y
 # CONFIG_GS_MMA7660 is not set
-CONFIG_GS_MMA8452=y
-# CONFIG_GS_KXTF9 is not set
-# CONFIG_GS_LIS3DH is not set
-# CONFIG_GS_L3G4200D is not set
-# CONFIG_GYRO_SENSOR_DEVICE is not set
-# CONFIG_INPUT_JOGBALL is not set
-# CONFIG_LIGHT_SENSOR_DEVICE is not set
-
-#
-# Hardware I/O ports
-#
 # CONFIG_SERIO is not set
-# CONFIG_GAMEPORT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
 # CONFIG_CONSOLE_TRANSLATIONS is not set
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-# CONFIG_VT_HW_CONSOLE_BINDING is not set
-CONFIG_DEVMEM=y
-CONFIG_DEVKMEM=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-# CONFIG_SERIAL_8250 is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_LEGACY_PTYS is not set
 CONFIG_SERIAL_RK29=y
-CONFIG_SERIAL_RK29_STANDARD=y
 CONFIG_UART0_RK29=y
 CONFIG_UART0_CTS_RTS_RK29=y
-# CONFIG_UART0_DMA_RK29 is not set
 CONFIG_UART1_RK29=y
 CONFIG_UART2_RK29=y
 CONFIG_UART2_CTS_RTS_RK29=y
-# CONFIG_UART2_DMA_RK29 is not set
-# CONFIG_UART3_RK29 is not set
 CONFIG_SERIAL_RK29_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
-# CONFIG_LEGACY_PTYS is not set
-# CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
-# CONFIG_R3964 is not set
-# CONFIG_RAW_DRIVER is not set
-# CONFIG_TCG_TPM is not set
-# CONFIG_DCC_TTY is not set
 CONFIG_I2C=y
-CONFIG_I2C_BOARDINFO=y
-CONFIG_I2C_COMPAT=y
-# CONFIG_I2C_CHARDEV is not set
-CONFIG_I2C_HELPER_AUTO=y
-
-#
-# I2C Hardware Bus support
-#
-CONFIG_I2C_RK29=y
-
-#
-# Now, there are four I2C interfaces selected by developer.
-#
-CONFIG_I2C0_RK29=y
-CONFIG_RK29_I2C0_CONTROLLER=y
-# CONFIG_RK29_I2C0_GPIO is not set
-CONFIG_I2C1_RK29=y
-CONFIG_RK29_I2C1_CONTROLLER=y
-# CONFIG_RK29_I2C1_GPIO is not set
-CONFIG_I2C2_RK29=y
-CONFIG_RK29_I2C2_CONTROLLER=y
-# CONFIG_RK29_I2C2_GPIO is not set
-CONFIG_I2C3_RK29=y
-CONFIG_RK29_I2C3_CONTROLLER=y
-# CONFIG_RK29_I2C3_GPIO is not set
-CONFIG_I2C_DEV_RK29=y
-
-#
-# Miscellaneous I2C Chip support
-#
-# CONFIG_DS1682 is not set
-# CONFIG_SENSORS_TSL2550 is not set
-# CONFIG_SENSORS_PCA963X is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-# CONFIG_SPI is not set
-CONFIG_ADC=y
-# CONFIG_ADC_RK28 is not set
 CONFIG_ADC_RK29=y
-
-#
-# Headset device support
-#
-# CONFIG_RK_HEADSET_DET is not set
-
-#
-# PPS support
-#
-# CONFIG_PPS is not set
-CONFIG_ARCH_REQUIRE_GPIOLIB=y
-CONFIG_GPIOLIB=y
-# CONFIG_DEBUG_GPIO is not set
-# CONFIG_GPIO_SYSFS is not set
-
-#
-# Memory mapped GPIO expanders:
-#
-
-#
-# I2C GPIO expanders:
-#
-# CONFIG_GPIO_MAX732X is not set
-# CONFIG_GPIO_PCA953X is not set
-# CONFIG_GPIO_PCF857X is not set
-
-#
-# PCI GPIO expanders:
-#
-
-#
-# SPI GPIO expanders:
-#
-
-#
-# AC97 GPIO expanders:
-#
-# CONFIG_GPIO_PCA9554 is not set
-# CONFIG_IOEXTEND_TCA6424 is not set
 CONFIG_EXPANDED_GPIO_NUM=0
 CONFIG_EXPANDED_GPIO_IRQ_NUM=0
-# CONFIG_EXPAND_GPIO_SOFT_INTERRUPT is not set
-CONFIG_SPI_FPGA_GPIO_NUM=96
-CONFIG_SPI_FPGA_GPIO_IRQ_NUM=16
-# CONFIG_W1 is not set
 CONFIG_POWER_SUPPLY=y
-# CONFIG_POWER_SUPPLY_DEBUG is not set
-# CONFIG_PDA_POWER is not set
-# CONFIG_BATTERY_DS2760 is not set
-# CONFIG_BATTERY_DS2782 is not set
-# CONFIG_BATTERY_BQ27x00 is not set
-# CONFIG_BATTERY_MAX17040 is not set
-# CONFIG_BATTERY_STC3100 is not set
 CONFIG_BATTERY_BQ27510=y
-# CONFIG_BATTERY_BQ27541 is not set
-# CONFIG_BATTERY_BQ3060 is not set
-# CONFIG_CHECK_BATT_CAPACITY is not set
 CONFIG_NO_BATTERY_IC=y
 # CONFIG_HWMON is not set
-# CONFIG_THERMAL is not set
-# CONFIG_WATCHDOG is not set
-CONFIG_SSB_POSSIBLE=y
-
-#
-# Sonics Silicon Backplane
-#
-# CONFIG_SSB is not set
-
-#
-# Multifunction device drivers
-#
-# CONFIG_MFD_CORE is not set
-# CONFIG_MFD_SM501 is not set
-# CONFIG_MFD_ASIC3 is not set
-# CONFIG_HTC_EGPIO is not set
-# CONFIG_HTC_PASIC3 is not set
-# CONFIG_TPS65010 is not set
-# CONFIG_TWL4030_CORE is not set
-# CONFIG_TPS65910_CORE is not set
-# CONFIG_MFD_TMIO is not set
-# CONFIG_MFD_T7L66XB is not set
-# CONFIG_MFD_TC6387XB is not set
-# CONFIG_MFD_TC6393XB is not set
-# CONFIG_PMIC_DA903X is not set
-# CONFIG_MFD_WM8400 is not set
-# CONFIG_MFD_WM831X_I2C is not set
-# CONFIG_MFD_WM8350_I2C is not set
-# CONFIG_MFD_PCF50633 is not set
-# CONFIG_AB3100_CORE is not set
 CONFIG_REGULATOR=y
-# CONFIG_REGULATOR_DEBUG is not set
-# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
-# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
-# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set
-# CONFIG_REGULATOR_BQ24022 is not set
-# CONFIG_REGULATOR_MAX1586 is not set
-# CONFIG_REGULATOR_LP3971 is not set
-# CONFIG_REGULATOR_TPS65023 is not set
-# CONFIG_REGULATOR_TPS6507X is not set
-# CONFIG_RK2818_REGULATOR_CHARGE is not set
-# CONFIG_RK2818_REGULATOR_LP8725 is not set
-# CONFIG_REGULATOR_ACT8891 is not set
 CONFIG_RK29_PWM_REGULATOR=y
 CONFIG_MEDIA_SUPPORT=y
-
-#
-# Multimedia core support
-#
 CONFIG_VIDEO_DEV=y
-CONFIG_VIDEO_V4L2_COMMON=y
-CONFIG_VIDEO_ALLOW_V4L1=y
-CONFIG_VIDEO_V4L1_COMPAT=y
-# CONFIG_DVB_CORE is not set
-CONFIG_VIDEO_MEDIA=y
-
-#
-# Multimedia drivers
-#
-# CONFIG_MEDIA_ATTACH is not set
-CONFIG_MEDIA_TUNER=y
 # CONFIG_MEDIA_TUNER_CUSTOMISE is not set
-CONFIG_MEDIA_TUNER_SIMPLE=y
-CONFIG_MEDIA_TUNER_TDA8290=y
-CONFIG_MEDIA_TUNER_TDA9887=y
-CONFIG_MEDIA_TUNER_TEA5761=y
-CONFIG_MEDIA_TUNER_TEA5767=y
-CONFIG_MEDIA_TUNER_MT20XX=y
-CONFIG_MEDIA_TUNER_XC2028=y
-CONFIG_MEDIA_TUNER_XC5000=y
-CONFIG_MEDIA_TUNER_MC44S803=y
-CONFIG_VIDEO_V4L2=y
-CONFIG_VIDEO_V4L1=y
-CONFIG_VIDEOBUF_GEN=y
-CONFIG_VIDEOBUF_DMA_CONTIG=y
-# CONFIG_VIDEO_RK29XX_VOUT is not set
-CONFIG_VIDEO_CAPTURE_DRIVERS=y
-# CONFIG_VIDEO_ADV_DEBUG is not set
-# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
 CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
-# CONFIG_VIDEO_VIVI is not set
-# CONFIG_VIDEO_CPIA is not set
-# CONFIG_VIDEO_CPIA2 is not set
-# CONFIG_VIDEO_SAA5246A is not set
-# CONFIG_VIDEO_SAA5249 is not set
 CONFIG_SOC_CAMERA=y
-# CONFIG_SOC_CAMERA_MT9M001 is not set
-# CONFIG_SOC_CAMERA_MT9M111 is not set
-# CONFIG_SOC_CAMERA_MT9M112 is not set
-# CONFIG_SOC_CAMERA_MT9T031 is not set
-# CONFIG_SOC_CAMERA_MT9T111 is not set
-# CONFIG_SOC_CAMERA_MT9P111 is not set
-# CONFIG_SOC_CAMERA_MT9D112 is not set
-# CONFIG_SOC_CAMERA_MT9D113 is not set
-# CONFIG_SOC_CAMERA_MT9V022 is not set
-# CONFIG_SOC_CAMERA_TW9910 is not set
-# CONFIG_SOC_CAMERA_PLATFORM is not set
-# CONFIG_SOC_CAMERA_OV772X is not set
-# CONFIG_SOC_CAMERA_OV7675 is not set
-# CONFIG_SOC_CAMERA_OV2655 is not set
 CONFIG_SOC_CAMERA_OV2659=y
-# CONFIG_SOC_CAMERA_OV9650 is not set
-# CONFIG_SOC_CAMERA_OV2640 is not set
-# CONFIG_SOC_CAMERA_OV3640 is not set
 CONFIG_SOC_CAMERA_OV5642=y
-CONFIG_OV5642_AUTOFOCUS=y
-# CONFIG_OV5642_FIXEDFOCUS is not set
-# CONFIG_SOC_CAMERA_OV5640 is not set
-# CONFIG_SOC_CAMERA_S5K6AA is not set
-# CONFIG_SOC_CAMERA_GT2005 is not set
-# CONFIG_SOC_CAMERA_GC0307 is not set
-# CONFIG_SOC_CAMERA_GC0308 is not set
-# CONFIG_SOC_CAMERA_GC0309 is not set
-# CONFIG_SOC_CAMERA_GC2015 is not set
-# CONFIG_SOC_CAMERA_HI253 is not set
-# CONFIG_SOC_CAMERA_HI704 is not set
-# CONFIG_SOC_CAMERA_SIV120B is not set
-# CONFIG_SOC_CAMERA_SID130B is not set
-# CONFIG_SOC_CAMERA_NT99250 is not set
-# CONFIG_VIDEO_SH_MOBILE_CEU is not set
 CONFIG_VIDEO_RK29=y
-CONFIG_VIDEO_RK29_WORK_ONEFRAME=y
-# CONFIG_VIDEO_RK29_WORK_PINGPONG is not set
-CONFIG_VIDEO_RK29_WORK_IPP=y
-# CONFIG_VIDEO_RK29_WORK_NOT_IPP is not set
-CONFIG_V4L_USB_DRIVERS=y
-# CONFIG_USB_VIDEO_CLASS is not set
-CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
-CONFIG_USB_GSPCA=m
-# CONFIG_USB_M5602 is not set
-# CONFIG_USB_STV06XX is not set
-# CONFIG_USB_GL860 is not set
-# CONFIG_USB_GSPCA_CONEX is not set
-# CONFIG_USB_GSPCA_ETOMS is not set
-# CONFIG_USB_GSPCA_FINEPIX is not set
-# CONFIG_USB_GSPCA_JEILINJ is not set
-# CONFIG_USB_GSPCA_MARS is not set
-# CONFIG_USB_GSPCA_MR97310A is not set
-# CONFIG_USB_GSPCA_OV519 is not set
-# CONFIG_USB_GSPCA_OV534 is not set
-# CONFIG_USB_GSPCA_PAC207 is not set
-# CONFIG_USB_GSPCA_PAC7311 is not set
-# CONFIG_USB_GSPCA_SN9C20X is not set
-# CONFIG_USB_GSPCA_SONIXB is not set
-# CONFIG_USB_GSPCA_SONIXJ is not set
-# CONFIG_USB_GSPCA_SPCA500 is not set
-# CONFIG_USB_GSPCA_SPCA501 is not set
-# CONFIG_USB_GSPCA_SPCA505 is not set
-# CONFIG_USB_GSPCA_SPCA506 is not set
-# CONFIG_USB_GSPCA_SPCA508 is not set
-# CONFIG_USB_GSPCA_SPCA561 is not set
-# CONFIG_USB_GSPCA_SQ905 is not set
-# CONFIG_USB_GSPCA_SQ905C is not set
-# CONFIG_USB_GSPCA_STK014 is not set
-# CONFIG_USB_GSPCA_SUNPLUS is not set
-# CONFIG_USB_GSPCA_T613 is not set
-# CONFIG_USB_GSPCA_TV8532 is not set
-# CONFIG_USB_GSPCA_VC032X is not set
-# CONFIG_USB_GSPCA_ZC3XX is not set
-# CONFIG_VIDEO_PVRUSB2 is not set
-# CONFIG_VIDEO_HDPVR is not set
-# CONFIG_VIDEO_EM28XX is not set
-# CONFIG_VIDEO_CX231XX is not set
-# CONFIG_VIDEO_USBVISION is not set
-# CONFIG_USB_VICAM is not set
-# CONFIG_USB_IBMCAM is not set
-# CONFIG_USB_KONICAWC is not set
-# CONFIG_USB_QUICKCAM_MESSENGER is not set
-# CONFIG_USB_ET61X251 is not set
-# CONFIG_VIDEO_OVCAMCHIP is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_SE401 is not set
-# CONFIG_USB_SN9C102 is not set
-# CONFIG_USB_STV680 is not set
-# CONFIG_USB_ZC0301 is not set
-# CONFIG_USB_PWC is not set
-CONFIG_USB_PWC_INPUT_EVDEV=y
-# CONFIG_USB_ZR364XX is not set
-# CONFIG_USB_STKWEBCAM is not set
-# CONFIG_USB_S2255 is not set
-CONFIG_RADIO_ADAPTERS=y
-# CONFIG_I2C_SI4713 is not set
-# CONFIG_RADIO_SI4713 is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_RADIO_SI470X is not set
-# CONFIG_USB_MR800 is not set
-# CONFIG_RADIO_TEA5764 is not set
-# CONFIG_SMS_SIANO_MDTV is not set
-# CONFIG_DAB is not set
-
-#
-# Graphics support
-#
-# CONFIG_VGASTATE is not set
-# CONFIG_VIDEO_OUTPUT_CONTROL is not set
 CONFIG_FB=y
-# CONFIG_FIRMWARE_EDID is not set
-# CONFIG_FB_DDC is not set
-# CONFIG_FB_BOOT_VESA_SUPPORT is not set
-CONFIG_FB_CFB_FILLRECT=y
-CONFIG_FB_CFB_COPYAREA=y
-CONFIG_FB_CFB_IMAGEBLIT=y
-# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
-# CONFIG_FB_SYS_FILLRECT is not set
-# CONFIG_FB_SYS_COPYAREA is not set
-# CONFIG_FB_SYS_IMAGEBLIT is not set
-# CONFIG_FB_FOREIGN_ENDIAN is not set
-# CONFIG_FB_SYS_FOPS is not set
-# CONFIG_FB_SVGALIB is not set
-# CONFIG_FB_MACMODES is not set
-# CONFIG_FB_BACKLIGHT is not set
-# CONFIG_FB_MODE_HELPERS is not set
-# CONFIG_FB_TILEBLITTING is not set
-
-#
-# Frame buffer hardware drivers
-#
-# CONFIG_FB_S1D13XXX is not set
-# CONFIG_FB_RK2818 is not set
 CONFIG_FB_RK29=y
-CONFIG_FB_WORK_IPP=y
-# CONFIG_FB_SCALING_OSD is not set
-# CONFIG_FB_ROTATE_VIDEO is not set
 CONFIG_CLOSE_WIN1_DYNAMIC=y
-# CONFIG_FB_VIRTUAL is not set
-# CONFIG_FB_METRONOME is not set
-# CONFIG_FB_MB862XX is not set
-# CONFIG_FB_BROADSHEET is not set
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 # CONFIG_LCD_CLASS_DEVICE is not set
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_BACKLIGHT_GENERIC is not set
-CONFIG_BACKLIGHT_RK29_BL=y
-# CONFIG_BACKLIGHT_RK29_NEWTON_BL is not set
-# CONFIG_FIH_TOUCHKEY_LED is not set
-# CONFIG_BACKLIGHT_AW9364 is not set
-# CONFIG_BUTTON_LIGHT is not set
-
-#
-# Display device support
-#
 CONFIG_DISPLAY_SUPPORT=y
-
-#
-# Display hardware drivers
-#
-# CONFIG_LCD_NULL is not set
-# CONFIG_LCD_TD043MGEA1 is not set
-# CONFIG_LCD_HX8357 is not set
-# CONFIG_LCD_TJ048NC01CA is not set
-# CONFIG_LCD_HL070VM4AU is not set
-# CONFIG_LCD_HSD070IDW1 is not set
-# CONFIG_LCD_RGB_TFT480800_25_E is not set
 CONFIG_LCD_HSD100PXN=y
-# CONFIG_LCD_HSD07PFW1 is not set
-# CONFIG_LCD_BYD8688FTGF is not set
-# CONFIG_LCD_B101AW06 is not set
-# CONFIG_LCD_LS035Y8DX02A is not set
-# CONFIG_LCD_CPTCLAA038LA31XE is not set
-# CONFIG_LCD_A060SE02 is not set
-# CONFIG_LCD_S1D13521 is not set
-# CONFIG_LCD_NT35582 is not set
-# CONFIG_LCD_NT35580 is not set
-# CONFIG_LCD_IPS1P5680_V1_E is not set
-# CONFIG_LCD_MCU_TFT480800_25_E is not set
-# CONFIG_LCD_NT35510 is not set
-# CONFIG_LCD_ILI9803_CPT4_3 is not set
-# CONFIG_DEFAULT_OUT_HDMI is not set
-# CONFIG_LCD_AT070TNA2 is not set
-# CONFIG_LCD_AT070TN93 is not set
-# CONFIG_LCD_TX23D88VM is not set
-
-#
-# HDMI
-#
 CONFIG_HDMI=y
-CONFIG_ANX7150=y
-# CONFIG_ANX9030 is not set
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-# CONFIG_FRAMEBUFFER_CONSOLE is not set
 CONFIG_LOGO=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
-CONFIG_LOGO_LINUX_CLUT224=y
-# CONFIG_LOGO_CHARGER_CLUT224 is not set
 CONFIG_SOUND=y
-# CONFIG_SOUND_OSS_CORE is not set
 CONFIG_SND=y
-CONFIG_SND_TIMER=y
-CONFIG_SND_PCM=y
-CONFIG_SND_JACK=y
-# CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_MIXER_OSS is not set
-# CONFIG_SND_PCM_OSS is not set
-# CONFIG_SND_HRTIMER is not set
-# CONFIG_SND_DYNAMIC_MINORS is not set
 # CONFIG_SND_SUPPORT_OLD_API is not set
 # CONFIG_SND_VERBOSE_PROCFS is not set
-# CONFIG_SND_VERBOSE_PRINTK is not set
-# CONFIG_SND_DEBUG is not set
-# CONFIG_SND_RAWMIDI_SEQ is not set
-# CONFIG_SND_OPL3_LIB_SEQ is not set
-# CONFIG_SND_OPL4_LIB_SEQ is not set
-# CONFIG_SND_SBAWE_SEQ is not set
-# CONFIG_SND_EMU10K1_SEQ is not set
 # CONFIG_SND_DRIVERS is not set
 # CONFIG_SND_ARM is not set
-CONFIG_SND_USB=y
-# CONFIG_SND_USB_AUDIO is not set
-# CONFIG_SND_USB_CAIAQ is not set
 CONFIG_SND_SOC=y
 CONFIG_SND_RK29_SOC=y
-CONFIG_SND_RK29_SOC_I2S=y
-# CONFIG_SND_RK29_SOC_I2S_2CH is not set
-CONFIG_SND_RK29_SOC_I2S_8CH=y
-# CONFIG_SND_RK29_SOC_WM8988 is not set
+CONFIG_SND_I2S_DMA_EVENT_STATIC=y
 CONFIG_SND_RK29_SOC_WM8900=y
-# CONFIG_SND_RK29_SOC_alc5621 is not set
-# CONFIG_SND_RK29_SOC_alc5631 is not set
-# CONFIG_SND_RK29_SOC_RT5625 is not set
-# CONFIG_SND_RK29_SOC_WM8994 is not set
-# CONFIG_SND_RK29_SOC_CS42L52 is not set
-# CONFIG_SND_RK29_CODEC_SOC_MASTER is not set
 CONFIG_SND_RK29_CODEC_SOC_SLAVE=y
-# CONFIG_ADJUST_VOL_BY_CODEC is not set
-CONFIG_SND_SOC_I2C_AND_SPI=y
-# CONFIG_SND_SOC_ALL_CODECS is not set
-CONFIG_SND_SOC_WM8900=y
-# CONFIG_SOUND_PRIME is not set
-CONFIG_HID_SUPPORT=y
-CONFIG_HID=y
-# CONFIG_HIDRAW is not set
-
-#
-# USB Input Devices
-#
-CONFIG_USB_HID=y
-# CONFIG_HID_PID is not set
-# CONFIG_USB_HIDDEV is not set
-
-#
-# Special HID drivers
-#
-# CONFIG_HID_A4TECH is not set
-# CONFIG_HID_APPLE is not set
-# CONFIG_HID_BELKIN is not set
-# CONFIG_HID_CHERRY is not set
-# CONFIG_HID_CHICONY is not set
-# CONFIG_HID_CYPRESS is not set
-# CONFIG_HID_DRAGONRISE is not set
-# CONFIG_HID_EZKEY is not set
-# CONFIG_HID_KYE is not set
-# CONFIG_HID_GYRATION is not set
-# CONFIG_HID_TWINHAN is not set
-# CONFIG_HID_KENSINGTON is not set
-# CONFIG_HID_LOGITECH is not set
-# CONFIG_HID_MICROSOFT is not set
-# CONFIG_HID_MONTEREY is not set
-# CONFIG_HID_NTRIG is not set
-# CONFIG_HID_PANTHERLORD is not set
-# CONFIG_HID_PETALYNX is not set
-# CONFIG_HID_SAMSUNG is not set
-# CONFIG_HID_SONY is not set
-# CONFIG_HID_SUNPLUS is not set
-# CONFIG_HID_GREENASIA is not set
-# CONFIG_HID_SMARTJOYPLUS is not set
-# CONFIG_HID_TOPSEED is not set
-# CONFIG_HID_THRUSTMASTER is not set
-# CONFIG_HID_ZEROPLUS is not set
-CONFIG_USB_SUPPORT=y
-CONFIG_USB_ARCH_HAS_HCD=y
-# CONFIG_USB_ARCH_HAS_OHCI is not set
-# CONFIG_USB_ARCH_HAS_EHCI is not set
 CONFIG_USB=y
-# CONFIG_USB_DEBUG is not set
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-
-#
-# Miscellaneous USB options
-#
-# CONFIG_USB_DEVICEFS is not set
-CONFIG_USB_DEVICE_CLASS=y
-# CONFIG_USB_DYNAMIC_MINORS is not set
-# CONFIG_USB_SUSPEND is not set
-# CONFIG_USB_OTG is not set
-# CONFIG_USB_OTG_WHITELIST is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
-# CONFIG_USB_MON is not set
-# CONFIG_USB_WUSB is not set
-# CONFIG_USB_WUSB_CBAF is not set
-
-#
-# USB Host Controller Drivers
-#
-# CONFIG_USB_C67X00_HCD is not set
-# CONFIG_USB_OXU210HP_HCD is not set
-# CONFIG_USB_ISP116X_HCD is not set
-# CONFIG_USB_ISP1760_HCD is not set
-# CONFIG_USB_ISP1362_HCD is not set
-# CONFIG_USB_SL811_HCD is not set
-# CONFIG_USB_R8A66597_HCD is not set
-# CONFIG_USB_HWA_HCD is not set
-# CONFIG_USB_MUSB_HDRC is not set
-# CONFIG_USB_GADGET_MUSB_HDRC is not set
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-# CONFIG_USB_WDM is not set
-# CONFIG_USB_TMC is not set
-
-#
-# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
-#
-
-#
-# also be needed; see USB_STORAGE Help for more info
-#
 CONFIG_USB_STORAGE=y
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_DATAFAB is not set
-# CONFIG_USB_STORAGE_FREECOM is not set
-# CONFIG_USB_STORAGE_ISD200 is not set
-# CONFIG_USB_STORAGE_USBAT is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_SDDR55 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_STORAGE_ALAUDA is not set
-# CONFIG_USB_STORAGE_ONETOUCH is not set
-# CONFIG_USB_STORAGE_KARMA is not set
-# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
-# CONFIG_USB_LIBUSUAL is not set
-
-#
-# USB Imaging devices
-#
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_MICROTEK is not set
-
-#
-# USB port drivers
-#
 CONFIG_USB_SERIAL=y
-# CONFIG_USB_SERIAL_CONSOLE is not set
-# CONFIG_USB_EZUSB is not set
 CONFIG_USB_SERIAL_GENERIC=y
-# CONFIG_USB_SERIAL_AIRCABLE is not set
-# CONFIG_USB_SERIAL_ARK3116 is not set
-# CONFIG_USB_SERIAL_BELKIN is not set
-# CONFIG_USB_SERIAL_CH341 is not set
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
-# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
-# CONFIG_USB_SERIAL_CP210X is not set
-# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
-# CONFIG_USB_SERIAL_EMPEG is not set
-# CONFIG_USB_SERIAL_FTDI_SIO is not set
-# CONFIG_USB_SERIAL_FUNSOFT is not set
-# CONFIG_USB_SERIAL_VISOR is not set
-# CONFIG_USB_SERIAL_IPAQ is not set
-# CONFIG_USB_SERIAL_IR is not set
-# CONFIG_USB_SERIAL_EDGEPORT is not set
-# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
-# CONFIG_USB_SERIAL_GARMIN is not set
-# CONFIG_USB_SERIAL_IPW is not set
-# CONFIG_USB_SERIAL_IUU is not set
-# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
-# CONFIG_USB_SERIAL_KEYSPAN is not set
-# CONFIG_USB_SERIAL_KLSI is not set
-# CONFIG_USB_SERIAL_KOBIL_SCT is not set
-# CONFIG_USB_SERIAL_MCT_U232 is not set
-# CONFIG_USB_SERIAL_MOS7720 is not set
-# CONFIG_USB_SERIAL_MOS7840 is not set
-# CONFIG_USB_SERIAL_MOTOROLA is not set
-# CONFIG_USB_SERIAL_NAVMAN is not set
-# CONFIG_USB_SERIAL_PL2303 is not set
-# CONFIG_USB_SERIAL_OTI6858 is not set
-# CONFIG_USB_SERIAL_QUALCOMM is not set
-# CONFIG_USB_SERIAL_SPCP8X5 is not set
-# CONFIG_USB_SERIAL_HP4X is not set
-# CONFIG_USB_SERIAL_SAFE is not set
-# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
-# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
-# CONFIG_USB_SERIAL_SYMBOL is not set
-# CONFIG_USB_SERIAL_TI is not set
-# CONFIG_USB_SERIAL_CYBERJACK is not set
-# CONFIG_USB_SERIAL_XIRCOM is not set
 CONFIG_USB_SERIAL_OPTION=y
-# CONFIG_USB_SERIAL_OMNINET is not set
-# CONFIG_USB_SERIAL_OPTICON is not set
-# CONFIG_USB_SERIAL_DEBUG is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_EMI62 is not set
-# CONFIG_USB_EMI26 is not set
-# CONFIG_USB_ADUTUX is not set
-# CONFIG_USB_SEVSEG is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_LEGOTOWER is not set
-# CONFIG_USB_LCD is not set
-# CONFIG_USB_BERRY_CHARGE is not set
-# CONFIG_USB_LED is not set
-# CONFIG_USB_CYPRESS_CY7C63 is not set
-# CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_IDMOUSE is not set
-# CONFIG_USB_FTDI_ELAN is not set
-# CONFIG_USB_APPLEDISPLAY is not set
-# CONFIG_USB_LD is not set
-# CONFIG_USB_TRANCEVIBRATOR is not set
-# CONFIG_USB_IOWARRIOR is not set
-# CONFIG_USB_TEST is not set
-# CONFIG_USB_ISIGHTFW is not set
-# CONFIG_USB_VST is not set
 CONFIG_USB_GADGET=y
-# CONFIG_USB_GADGET_DEBUG is not set
-# CONFIG_USB_GADGET_DEBUG_FILES is not set
-CONFIG_USB_GADGET_VBUS_DRAW=2
-CONFIG_USB_GADGET_SELECTED=y
-# CONFIG_USB_GADGET_AT91 is not set
-# CONFIG_USB_GADGET_ATMEL_USBA is not set
-# CONFIG_USB_GADGET_FSL_USB2 is not set
-# CONFIG_USB_GADGET_LH7A40X is not set
-# CONFIG_USB_GADGET_OMAP is not set
-# CONFIG_USB_GADGET_PXA25X is not set
-# CONFIG_USB_GADGET_R8A66597 is not set
-# CONFIG_USB_GADGET_PXA27X is not set
-# CONFIG_USB_GADGET_S3C_HSOTG is not set
-# CONFIG_USB_GADGET_IMX is not set
-# CONFIG_USB_GADGET_S3C2410 is not set
-# CONFIG_USB_GADGET_M66592 is not set
-# CONFIG_USB_GADGET_AMD5536UDC is not set
-# CONFIG_USB_GADGET_FSL_QE is not set
-# CONFIG_USB_GADGET_CI13XXX is not set
-# CONFIG_USB_GADGET_NET2280 is not set
-# CONFIG_USB_GADGET_GOKU is not set
-# CONFIG_USB_GADGET_LANGWELL is not set
-CONFIG_USB_GADGET_DWC_OTG=y
-CONFIG_USB_DWC_OTG=y
-# CONFIG_USB_GADGET_DUMMY_HCD is not set
-CONFIG_USB_GADGET_DUALSPEED=y
-# CONFIG_USB_ZERO is not set
-# CONFIG_USB_AUDIO is not set
-# CONFIG_USB_ETH is not set
-# CONFIG_USB_GADGETFS is not set
-# CONFIG_USB_FILE_STORAGE is not set
-# CONFIG_USB_G_SERIAL is not set
-# CONFIG_USB_MIDI_GADGET is not set
-# CONFIG_USB_G_PRINTER is not set
-CONFIG_USB_ANDROID=y
-# CONFIG_USB_ANDROID_ACM is not set
-CONFIG_USB_ANDROID_ADB=y
-CONFIG_USB_ANDROID_MASS_STORAGE=y
-# CONFIG_USB_ANDROID_RNDIS is not set
-# CONFIG_USB_CDC_COMPOSITE is not set
-
-#
-# OTG and related infrastructure
-#
-# CONFIG_USB_GPIO_VBUS is not set
-# CONFIG_NOP_USB_XCEIV is not set
 CONFIG_USB11_HOST=y
-CONFIG_USB11_HOST_EN=y
 CONFIG_USB20_HOST=y
-CONFIG_USB20_HOST_EN=y
 CONFIG_USB20_OTG=y
-# CONFIG_DWC_OTG_HOST_ONLY is not set
-CONFIG_DWC_OTG_DEVICE_ONLY=y
-# CONFIG_DWC_OTG_BOTH_HOST_SLAVE is not set
-CONFIG_DWC_CONN_EN=y
-# CONFIG_DWC_OTG_DEBUG is not set
-# CONFIG_DWC_REMOTE_WAKEUP is not set
-CONFIG_DWC_OTG=y
 CONFIG_MMC=y
-# CONFIG_MMC_DEBUG is not set
 CONFIG_MMC_UNSAFE_RESUME=y
 CONFIG_MMC_EMBEDDED_SDIO=y
 CONFIG_MMC_PARANOID_SD_INIT=y
-
-#
-# MMC/SD/SDIO Card Drivers
-#
-CONFIG_MMC_BLOCK=y
-CONFIG_MMC_BLOCK_BOUNCE=y
-# CONFIG_MMC_BLOCK_DEFERRED_RESUME is not set
-# CONFIG_SDIO_UART is not set
-# CONFIG_MMC_TEST is not set
-
-#
-# MMC/SD/SDIO Host Controller Drivers
-#
 CONFIG_SDMMC_RK29=y
-
-#
-# Now, there are two SDMMC controllers selected, SDMMC0 and SDMMC1.
-#
-# CONFIG_SDMMC_RK29_OLD is not set
-CONFIG_SDMMC0_RK29=y
-CONFIG_SDMMC1_RK29=y
-# CONFIG_MMC_SDHCI is not set
-# CONFIG_MMC_AT91 is not set
-# CONFIG_MMC_ATMELMCI is not set
-# CONFIG_MEMSTICK is not set
-# CONFIG_NEW_LEDS is not set
 CONFIG_SWITCH=y
 CONFIG_SWITCH_GPIO=y
-# CONFIG_ACCESSIBILITY is not set
-CONFIG_RTC_LIB=y
 CONFIG_RTC_CLASS=y
-CONFIG_RTC_HCTOSYS=y
-CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
-# CONFIG_RTC_DEBUG is not set
-
-#
-# RTC interfaces
-#
-CONFIG_RTC_INTF_SYSFS=y
-CONFIG_RTC_INTF_PROC=y
-CONFIG_RTC_INTF_DEV=y
-# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
-CONFIG_RTC_INTF_ALARM=y
-CONFIG_RTC_INTF_ALARM_DEV=y
-# CONFIG_RTC_DRV_TEST is not set
-
-#
-# I2C RTC drivers
-#
 CONFIG_RTC_HYM8563=y
-# CONFIG_RTC_M41T66 is not set
-# CONFIG_RTC_DRV_DS1307 is not set
-# CONFIG_RTC_DRV_DS1374 is not set
-# CONFIG_RTC_DRV_DS1672 is not set
-# CONFIG_RTC_DRV_MAX6900 is not set
-# CONFIG_RTC_DRV_RS5C372 is not set
-# CONFIG_RTC_DRV_ISL1208 is not set
-# CONFIG_RTC_DRV_X1205 is not set
-# CONFIG_RTC_DRV_PCF8563 is not set
-# CONFIG_RTC_DRV_PCF8583 is not set
-# CONFIG_RTC_DRV_M41T80 is not set
-# CONFIG_RTC_DRV_S35390A is not set
-# CONFIG_RTC_DRV_S35392A is not set
-# CONFIG_RTC_DRV_FM3130 is not set
-# CONFIG_RTC_DRV_RX8581 is not set
-# CONFIG_RTC_DRV_RX8025 is not set
-
-#
-# SPI RTC drivers
-#
-
-#
-# Platform RTC drivers
-#
-# CONFIG_RTC_DRV_CMOS is not set
-# CONFIG_RTC_DRV_DS1286 is not set
-# CONFIG_RTC_DRV_DS1511 is not set
-# CONFIG_RTC_DRV_DS1553 is not set
-# CONFIG_RTC_DRV_DS1742 is not set
-# CONFIG_RTC_DRV_STK17TA8 is not set
-# CONFIG_RTC_DRV_M48T86 is not set
-# CONFIG_RTC_DRV_M48T35 is not set
-# CONFIG_RTC_DRV_M48T59 is not set
-# CONFIG_RTC_DRV_BQ4802 is not set
-# CONFIG_RTC_DRV_V3020 is not set
-
-#
-# on-CPU RTC drivers
-#
-# CONFIG_DMADEVICES is not set
-# CONFIG_AUXDISPLAY is not set
-# CONFIG_UIO is not set
-
-#
-# TI VLYNQ
-#
 CONFIG_STAGING=y
-# CONFIG_STAGING_EXCLUDE_BUILD is not set
-# CONFIG_USB_IP_COMMON is not set
-# CONFIG_PRISM2_USB is not set
-# CONFIG_ECHO is not set
-# CONFIG_COMEDI is not set
-# CONFIG_ASUS_OLED is not set
-# CONFIG_TRANZPORT is not set
-
-#
-# Android
-#
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
 CONFIG_ANDROID_LOGGER=y
 CONFIG_ANDROID_RAM_CONSOLE=y
-CONFIG_ANDROID_RAM_CONSOLE_ENABLE_VERBOSE=y
 CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION=y
-CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_DATA_SIZE=128
-CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_ECC_SIZE=16
-CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE=8
-CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_POLYNOMIAL=0x11d
-# CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT is not set
-CONFIG_ANDROID_TIMED_OUTPUT=y
 CONFIG_ANDROID_TIMED_GPIO=y
 CONFIG_ANDROID_LOW_MEMORY_KILLER=y
-# CONFIG_DST is not set
-# CONFIG_POHMELFS is not set
-# CONFIG_PLAN9AUTH is not set
-# CONFIG_LINE6_USB is not set
-# CONFIG_USB_SERIAL_QUATECH2 is not set
-# CONFIG_USB_SERIAL_QUATECH_USB2 is not set
-# CONFIG_VT6656 is not set
-# CONFIG_FB_UDL is not set
-
-#
-# RAR Register Driver
-#
-# CONFIG_RAR_REGISTER is not set
-# CONFIG_IIO is not set
-
-#
-# GPU Vivante
-#
-CONFIG_VIVANTE=y
-
-#
-# IPP
-#
-CONFIG_RK29_IPP=y
-CONFIG_DEINTERLACE=y
-
-#
-# CMMB
-#
 # CONFIG_CMMB is not set
-# CONFIG_TEST_CODE is not set
-# CONFIG_RK29_SMC is not set
-
-#
-# CIR support
-#
-# CONFIG_RK_CIR is not set
-
-#
-# File systems
-#
-# CONFIG_EXT2_FS is not set
 CONFIG_EXT3_FS=y
-CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
 # CONFIG_EXT3_FS_XATTR is not set
 CONFIG_EXT4_FS=y
 # CONFIG_EXT4_FS_XATTR is not set
-# CONFIG_EXT4_DEBUG is not set
-CONFIG_JBD=y
-CONFIG_JBD2=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-# CONFIG_FS_POSIX_ACL is not set
-# CONFIG_XFS_FS is not set
-# CONFIG_OCFS2_FS is not set
-# CONFIG_BTRFS_FS is not set
-# CONFIG_NILFS2_FS is not set
-CONFIG_FILE_LOCKING=y
-CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
-CONFIG_INOTIFY=y
-CONFIG_INOTIFY_USER=y
-# CONFIG_QUOTA is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=y
-# CONFIG_CUSE is not set
-
-#
-# Caches
-#
-# CONFIG_FSCACHE is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-CONFIG_FAT_FS=y
-# CONFIG_MSDOS_FS is not set
 CONFIG_VFAT_FS=y
-CONFIG_FAT_DEFAULT_CODEPAGE=437
-CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_SYSCTL=y
-CONFIG_PROC_PAGE_MONITOR=y
-CONFIG_SYSFS=y
 CONFIG_TMPFS=y
-# CONFIG_TMPFS_POSIX_ACL is not set
-# CONFIG_HUGETLB_PAGE is not set
-# CONFIG_CONFIGFS_FS is not set
-CONFIG_MISC_FILESYSTEMS=y
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_YAFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
 CONFIG_CRAMFS=y
-# CONFIG_SQUASHFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_OMFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_ROMFS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
 # CONFIG_NETWORK_FILESYSTEMS is not set
-
-#
-# Partition Types
-#
-# CONFIG_PARTITION_ADVANCED is not set
-CONFIG_MSDOS_PARTITION=y
-CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
 CONFIG_NLS_CODEPAGE_437=y
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
 CONFIG_NLS_CODEPAGE_850=y
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
 CONFIG_NLS_CODEPAGE_936=y
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
 CONFIG_NLS_ISO8859_1=y
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
 CONFIG_NLS_ISO8859_15=y
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
 CONFIG_NLS_UTF8=y
-# CONFIG_DLM is not set
-
-#
-# Kernel hacking
-#
 CONFIG_PRINTK_TIME=y
-CONFIG_ENABLE_WARN_DEPRECATED=y
-CONFIG_ENABLE_MUST_CHECK=y
-CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
-# CONFIG_STRIP_ASM_SYMS is not set
-# CONFIG_UNUSED_SYMBOLS is not set
-# CONFIG_DEBUG_FS is not set
-# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_FS=y
 CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SHIRQ is not set
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
-CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
 CONFIG_DETECT_HUNG_TASK=y
-# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
-CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 # CONFIG_SCHED_DEBUG is not set
 CONFIG_SCHEDSTATS=y
 CONFIG_TIMER_STATS=y
-# CONFIG_DEBUG_OBJECTS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_KMEMLEAK is not set
 # CONFIG_DEBUG_PREEMPT is not set
-# CONFIG_DEBUG_RT_MUTEXES is not set
-# CONFIG_RT_MUTEX_TESTER is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_MUTEXES is not set
-# CONFIG_DEBUG_LOCK_ALLOC is not set
-# CONFIG_PROVE_LOCKING is not set
-# CONFIG_LOCK_STAT is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
-# CONFIG_DEBUG_KOBJECT is not set
-# CONFIG_DEBUG_HIGHMEM is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_VM is not set
-# CONFIG_DEBUG_WRITECOUNT is not set
-# CONFIG_DEBUG_MEMORY_INIT is not set
-# CONFIG_DEBUG_LIST is not set
-# CONFIG_DEBUG_SG is not set
-# CONFIG_DEBUG_NOTIFIERS is not set
-# CONFIG_DEBUG_CREDENTIALS is not set
-# CONFIG_BOOT_PRINTK_DELAY is not set
-# CONFIG_RCU_TORTURE_TEST is not set
-# CONFIG_RCU_CPU_STALL_DETECTOR is not set
-# CONFIG_BACKTRACE_SELF_TEST is not set
-# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
-# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
-# CONFIG_FAULT_INJECTION is not set
-# CONFIG_LATENCYTOP is not set
-# CONFIG_PAGE_POISONING is not set
-CONFIG_HAVE_FUNCTION_TRACER=y
-CONFIG_TRACING_SUPPORT=y
 # CONFIG_FTRACE is not set
-# CONFIG_SAMPLES is not set
-CONFIG_HAVE_ARCH_KGDB=y
-# CONFIG_KGDB is not set
-CONFIG_ARM_UNWIND=y
-# CONFIG_DEBUG_USER is not set
-CONFIG_DEBUG_ERRORS=y
-# CONFIG_DEBUG_STACK_USAGE is not set
-# CONFIG_DEBUG_LL is not set
-
-#
-# Security options
-#
-# CONFIG_KEYS is not set
-# CONFIG_SECURITY is not set
-# CONFIG_SECURITYFS is not set
-# CONFIG_SECURITY_FILE_CAPABILITIES is not set
-CONFIG_CRYPTO=y
-
-#
-# Crypto core or helper
-#
-CONFIG_CRYPTO_ALGAPI=y
-CONFIG_CRYPTO_ALGAPI2=y
-CONFIG_CRYPTO_AEAD2=y
-CONFIG_CRYPTO_BLKCIPHER=y
-CONFIG_CRYPTO_BLKCIPHER2=y
-CONFIG_CRYPTO_HASH=y
-CONFIG_CRYPTO_HASH2=y
-CONFIG_CRYPTO_RNG2=y
-CONFIG_CRYPTO_PCOMP=y
-CONFIG_CRYPTO_MANAGER=y
-CONFIG_CRYPTO_MANAGER2=y
-# CONFIG_CRYPTO_GF128MUL is not set
-# CONFIG_CRYPTO_NULL is not set
-CONFIG_CRYPTO_WORKQUEUE=y
-# CONFIG_CRYPTO_CRYPTD is not set
-# CONFIG_CRYPTO_AUTHENC is not set
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Authenticated Encryption with Associated Data
-#
-# CONFIG_CRYPTO_CCM is not set
-# CONFIG_CRYPTO_GCM is not set
-# CONFIG_CRYPTO_SEQIV is not set
-
-#
-# Block modes
-#
-CONFIG_CRYPTO_CBC=y
-# CONFIG_CRYPTO_CTR is not set
-# CONFIG_CRYPTO_CTS is not set
-CONFIG_CRYPTO_ECB=y
-# CONFIG_CRYPTO_LRW is not set
-# CONFIG_CRYPTO_PCBC is not set
-# CONFIG_CRYPTO_XTS is not set
-
-#
-# Hash modes
-#
-# CONFIG_CRYPTO_HMAC is not set
-# CONFIG_CRYPTO_XCBC is not set
-# CONFIG_CRYPTO_VMAC is not set
-
-#
-# Digest
-#
-CONFIG_CRYPTO_CRC32C=y
-# CONFIG_CRYPTO_GHASH is not set
-# CONFIG_CRYPTO_MD4 is not set
-CONFIG_CRYPTO_MD5=y
-# CONFIG_CRYPTO_MICHAEL_MIC is not set
-# CONFIG_CRYPTO_RMD128 is not set
-# CONFIG_CRYPTO_RMD160 is not set
-# CONFIG_CRYPTO_RMD256 is not set
-# CONFIG_CRYPTO_RMD320 is not set
-CONFIG_CRYPTO_SHA1=y
-# CONFIG_CRYPTO_SHA256 is not set
-# CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_TGR192 is not set
-# CONFIG_CRYPTO_WP512 is not set
-
-#
-# Ciphers
-#
-# CONFIG_CRYPTO_AES is not set
-# CONFIG_CRYPTO_ANUBIS is not set
 CONFIG_CRYPTO_ARC4=y
-# CONFIG_CRYPTO_BLOWFISH is not set
-# CONFIG_CRYPTO_CAMELLIA is not set
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-CONFIG_CRYPTO_DES=y
-# CONFIG_CRYPTO_FCRYPT is not set
-# CONFIG_CRYPTO_KHAZAD is not set
-# CONFIG_CRYPTO_SALSA20 is not set
-# CONFIG_CRYPTO_SEED is not set
-# CONFIG_CRYPTO_SERPENT is not set
-# CONFIG_CRYPTO_TEA is not set
 CONFIG_CRYPTO_TWOFISH=y
-CONFIG_CRYPTO_TWOFISH_COMMON=y
-
-#
-# Compression
-#
-# CONFIG_CRYPTO_DEFLATE is not set
-# CONFIG_CRYPTO_ZLIB is not set
-# CONFIG_CRYPTO_LZO is not set
-
-#
-# Random Number Generation
-#
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
-CONFIG_CRYPTO_HW=y
-# CONFIG_BINARY_PRINTF is not set
-
-#
-# Library routines
-#
-CONFIG_BITREVERSE=y
-CONFIG_GENERIC_FIND_LAST_BIT=y
-CONFIG_CRC_CCITT=y
-CONFIG_CRC16=y
-# CONFIG_CRC_T10DIF is not set
-# CONFIG_CRC_ITU_T is not set
-CONFIG_CRC32=y
-# CONFIG_CRC7 is not set
-CONFIG_LIBCRC32C=y
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
-CONFIG_DECOMPRESS_GZIP=y
-CONFIG_REED_SOLOMON=y
-CONFIG_REED_SOLOMON_ENC8=y
-CONFIG_REED_SOLOMON_DEC8=y
-CONFIG_TEXTSEARCH=y
-CONFIG_TEXTSEARCH_KMP=y
-CONFIG_TEXTSEARCH_BM=y
-CONFIG_TEXTSEARCH_FSM=y
-CONFIG_HAS_IOMEM=y
-CONFIG_HAS_IOPORT=y
-CONFIG_HAS_DMA=y
-CONFIG_NLATTR=y
index c9dc742bedadc8f2caab65cda2a67601acd6259e..3253901ed3aec776eb30a864639e4a4ff60421b1 100644 (file)
@@ -1841,7 +1841,7 @@ CONFIG_SND_RK29_SOC_I2S_8CH=y
 CONFIG_SND_I2S_DMA_EVENT_STATIC=y
 # CONFIG_SND_RK29_SOC_WM8988 is not set
 # CONFIG_SND_RK29_SOC_WM8900 is not set
-# CONFIG_SND_RK29_SOC_alc5621 is not set
+# CONFIG_SND_RK29_SOC_RT5621 is not set
 CONFIG_SND_RK29_SOC_RT5631=y
 # CONFIG_SND_RK29_SOC_RT5625 is not set
 # CONFIG_SND_RK29_SOC_WM8994 is not set
index 89ed26a541bd5d8b9575434ababa17aa19d08d94..5a094da7cbaf2db3865cb18942309bd5d0374289 100755 (executable)
@@ -1066,6 +1066,7 @@ CONFIG_GPIOLIB=y
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
 CONFIG_GPIO_WM831X=y
+CONFIG_GPIO_WM8994=y
 
 #
 # PCI GPIO expanders:
@@ -1128,13 +1129,13 @@ CONFIG_MFD_CORE=y
 # CONFIG_MFD_TC6387XB is not set
 # CONFIG_MFD_TC6393XB is not set
 # CONFIG_PMIC_DA903X is not set
-# CONFIG_MFD_WM8994 is not set
 # CONFIG_MFD_WM8400 is not set
 CONFIG_MFD_WM831X=y
 # CONFIG_MFD_WM831X_I2C is not set
 CONFIG_MFD_WM831X_SPI=y
 # CONFIG_MFD_WM831X_SPI_A22 is not set
 # CONFIG_MFD_WM8350_I2C is not set
+CONFIG_MFD_WM8994=y
 # CONFIG_MFD_PCF50633 is not set
 # CONFIG_MFD_MC13783 is not set
 # CONFIG_AB3100_CORE is not set
@@ -1147,6 +1148,7 @@ CONFIG_REGULATOR=y
 # CONFIG_REGULATOR_BQ24022 is not set
 # CONFIG_REGULATOR_MAX1586 is not set
 CONFIG_REGULATOR_WM831X=y
+CONFIG_REGULATOR_WM8994=y
 # CONFIG_REGULATOR_LP3971 is not set
 # CONFIG_REGULATOR_TPS65023 is not set
 # CONFIG_REGULATOR_TPS6507X is not set
@@ -1660,7 +1662,7 @@ CONFIG_MMC_BLOCK_BOUNCE=y
 #
 # MMC/SD/SDIO Host Controller Drivers
 #
-CONFIG_SDMMC_RK29_OLD=y
+CONFIG_SDMMC_RK29_OLD=y
 CONFIG_SDMMC_RK29=y
 
 #
diff --git a/arch/arm/configs/rk29_td8801_v2_defconfig b/arch/arm/configs/rk29_td8801_v2_defconfig
new file mode 100644 (file)
index 0000000..f6ab3eb
--- /dev/null
@@ -0,0 +1,2162 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32.27
+# Fri Oct 28 10:41:46 2011
+#
+CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_HAVE_SCHED_CLOCK=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_ARCH_HAS_CPUFREQ=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_LZO=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+# CONFIG_KERNEL_LZMA is not set
+CONFIG_KERNEL_LZO=y
+# CONFIG_SWAP is not set
+# CONFIG_SYSVIPC is not set
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_CGROUPS=y
+CONFIG_CGROUP_DEBUG=y
+# CONFIG_CGROUP_NS is not set
+CONFIG_CGROUP_FREEZER=y
+# CONFIG_CGROUP_DEVICE is not set
+# CONFIG_CPUSETS is not set
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+# CONFIG_CGROUP_MEM_RES_CTLR is not set
+CONFIG_CGROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+CONFIG_RT_GROUP_SCHED=y
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_PANIC_TIMEOUT=5
+CONFIG_EMBEDDED=y
+CONFIG_UID16=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_ELF_CORE is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_ASHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_COMPAT_BRK=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_SLOW_WORK is not set
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_FREEZER=y
+
+#
+# System Type
+#
+CONFIG_MMU=y
+# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_AT91 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_GEMINI is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_MXC is not set
+# CONFIG_ARCH_STMP3XXX is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_NOMADIK is not set
+# CONFIG_ARCH_IOP13XX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IXP23XX is not set
+# CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP4XX is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_KIRKWOOD is not set
+# CONFIG_ARCH_LOKI is not set
+# CONFIG_ARCH_MV78XX0 is not set
+# CONFIG_ARCH_ORION5X is not set
+# CONFIG_ARCH_MMP is not set
+# CONFIG_ARCH_KS8695 is not set
+# CONFIG_ARCH_NS9XXX is not set
+# CONFIG_ARCH_W90X900 is not set
+# CONFIG_ARCH_PNX4008 is not set
+# CONFIG_ARCH_PXA is not set
+# CONFIG_ARCH_MSM is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_S3C2410 is not set
+# CONFIG_ARCH_S3C64XX is not set
+# CONFIG_ARCH_S5PC1XX is not set
+# CONFIG_ARCH_SHARK is not set
+# CONFIG_ARCH_LH7A40X is not set
+# CONFIG_ARCH_U300 is not set
+# CONFIG_ARCH_DAVINCI is not set
+# CONFIG_ARCH_OMAP is not set
+# CONFIG_ARCH_BCMRING is not set
+CONFIG_ARCH_RK29=y
+# CONFIG_MACH_RK29SDK is not set
+# CONFIG_MACH_RK29SDK_DDR3 is not set
+# CONFIG_MACH_RK29WINACCORD is not set
+# CONFIG_MACH_RK29FIH is not set
+# CONFIG_MACH_RK29_MALATA is not set
+# CONFIG_MACH_RK29_PHONESDK is not set
+# CONFIG_MACH_RK29_A22 is not set
+# CONFIG_MACH_RK29_TD8801 is not set
+CONFIG_MACH_RK29_TD8801_V2=y
+# CONFIG_MACH_RK29_PHONEPADSDK is not set
+# CONFIG_MACH_RK29_newton is not set
+# CONFIG_DDR_TYPE_DDRII is not set
+CONFIG_DDR_TYPE_LPDDR=y
+# CONFIG_DDR_TYPE_DDR3_800D is not set
+# CONFIG_DDR_TYPE_DDR3_800E is not set
+# CONFIG_DDR_TYPE_DDR3_1066E is not set
+# CONFIG_DDR_TYPE_DDR3_1066F is not set
+# CONFIG_DDR_TYPE_DDR3_1066G is not set
+# CONFIG_DDR_TYPE_DDR3_1333F is not set
+# CONFIG_DDR_TYPE_DDR3_1333G is not set
+# CONFIG_DDR_TYPE_DDR3_1333H is not set
+# CONFIG_DDR_TYPE_DDR3_1333J is not set
+# CONFIG_DDR_TYPE_DDR3_1600G is not set
+# CONFIG_DDR_TYPE_DDR3_1600H is not set
+# CONFIG_DDR_TYPE_DDR3_1600J is not set
+# CONFIG_DDR_TYPE_DDR3_1600K is not set
+# CONFIG_DDR_TYPE_DDR3_1866J is not set
+# CONFIG_DDR_TYPE_DDR3_1866K is not set
+# CONFIG_DDR_TYPE_DDR3_1866L is not set
+# CONFIG_DDR_TYPE_DDR3_1866M is not set
+# CONFIG_DDR_TYPE_DDR3_2133K is not set
+# CONFIG_DDR_TYPE_DDR3_2133L is not set
+# CONFIG_DDR_TYPE_DDR3_2133M is not set
+# CONFIG_DDR_TYPE_DDR3_2133N is not set
+# CONFIG_DDR_TYPE_DDR3_DEFAULT is not set
+CONFIG_RK29_MEM_SIZE_M=512
+CONFIG_DDR_SDRAM_FREQ=192
+# CONFIG_DDR_RECONFIG is not set
+CONFIG_WIFI_CONTROL_FUNC=y
+
+#
+# RK29 VPU (Video Processing Unit) support
+#
+CONFIG_RK29_VPU=y
+CONFIG_RK29_VPU_SERVICE=y
+# CONFIG_RK29_VPU_DEBUG is not set
+CONFIG_RK29_JTAG=y
+CONFIG_RK29_LAST_LOG=y
+
+#
+# support for RK29 power manage
+#
+# CONFIG_RK29_WORKING_POWER_MANAGEMENT is not set
+CONFIG_RK29_CLK_SWITCH_TO_32K=y
+CONFIG_RK29_GPIO_SUSPEND=y
+# CONFIG_RK29_SPI_INSRAM is not set
+CONFIG_RK29_I2C_INSRAM=y
+# CONFIG_RK29_CHARGE_EARLYSUSPEND is not set
+
+#
+# Processor Type
+#
+CONFIG_CPU_32=y
+CONFIG_CPU_32v6K=y
+CONFIG_CPU_V7=y
+CONFIG_CPU_32v7=y
+CONFIG_CPU_ABRT_EV7=y
+CONFIG_CPU_PABRT_V7=y
+CONFIG_CPU_CACHE_V7=y
+CONFIG_CPU_CACHE_VIPT=y
+CONFIG_CPU_COPY_V6=y
+CONFIG_CPU_TLB_V7=y
+CONFIG_CPU_HAS_ASID=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
+
+#
+# Processor Features
+#
+CONFIG_ARM_THUMB=y
+CONFIG_ARM_THUMBEE=y
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_BPREDICT_DISABLE is not set
+CONFIG_HAS_TLS_REG=y
+CONFIG_ARM_L1_CACHE_SHIFT=6
+# CONFIG_ARM_ERRATA_430973 is not set
+# CONFIG_ARM_ERRATA_458693 is not set
+# CONFIG_ARM_ERRATA_460075 is not set
+CONFIG_ARM_GIC=y
+CONFIG_PL330=y
+CONFIG_COMMON_CLKDEV=y
+
+#
+# Bus support
+#
+# CONFIG_PCI_SYSCALL is not set
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Kernel Features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_VMSPLIT_3G=y
+# CONFIG_VMSPLIT_2G is not set
+# CONFIG_VMSPLIT_1G is not set
+CONFIG_PAGE_OFFSET=0xC0000000
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+CONFIG_PREEMPT=y
+CONFIG_HZ=100
+# CONFIG_THUMB2_KERNEL is not set
+CONFIG_AEABI=y
+# CONFIG_OABI_COMPAT is not set
+# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
+# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
+CONFIG_HIGHMEM=y
+# CONFIG_HIGHPTE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=32768
+CONFIG_ALIGNMENT_TRAP=y
+# CONFIG_UACCESS_WITH_MEMCPY is not set
+
+#
+# Boot options
+#
+CONFIG_ZBOOT_ROM_TEXT=0
+CONFIG_ZBOOT_ROM_BSS=0
+CONFIG_CMDLINE=""
+# CONFIG_XIP_KERNEL is not set
+CONFIG_KEXEC=y
+CONFIG_ATAGS_PROC=y
+
+#
+# CPU Power Management
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=y
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+# CONFIG_CPU_IDLE is not set
+
+#
+# Floating point emulation
+#
+
+#
+# At least one emulation must be selected
+#
+CONFIG_VFP=y
+CONFIG_VFPv3=y
+CONFIG_NEON=y
+
+#
+# Userspace binary formats
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_HAVE_AOUT=y
+# CONFIG_BINFMT_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Power management options
+#
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HAS_WAKELOCK=y
+CONFIG_HAS_EARLYSUSPEND=y
+CONFIG_WAKELOCK=y
+CONFIG_WAKELOCK_STAT=y
+CONFIG_USER_WAKELOCK=y
+CONFIG_EARLYSUSPEND=y
+# CONFIG_NO_USER_SPACE_SCREEN_ACCESS_CONTROL is not set
+# CONFIG_CONSOLE_EARLYSUSPEND is not set
+CONFIG_FB_EARLYSUSPEND=y
+# CONFIG_APM_EMULATION is not set
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+# CONFIG_INET_LRO is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+CONFIG_ANDROID_PARANOID_NETWORK=y
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=y
+CONFIG_BT_L2CAP=y
+CONFIG_BT_SCO=y
+CONFIG_BT_RFCOMM=y
+CONFIG_BT_RFCOMM_TTY=y
+# CONFIG_BT_BNEP is not set
+# CONFIG_BT_HIDP is not set
+
+#
+# Bluetooth device drivers
+#
+# CONFIG_BT_HCIBTUSB is not set
+# CONFIG_BT_HCIBTSDIO is not set
+CONFIG_BT_HCIUART=y
+CONFIG_BT_HCIUART_H4=y
+# CONFIG_BT_HCIUART_BCSP is not set
+# CONFIG_BT_HCIUART_LL is not set
+# CONFIG_BT_HCIBCM203X is not set
+# CONFIG_BT_HCIBPA10X is not set
+# CONFIG_BT_HCIBFUSB is not set
+# CONFIG_BT_HCIVHCI is not set
+# CONFIG_BT_MRVL is not set
+CONFIG_BT_HCIBCM4325=y
+CONFIG_IDBLOCK=y
+# CONFIG_WIFI_MAC is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+# CONFIG_LIB80211 is not set
+
+#
+# CFG80211 needs to be enabled for MAC80211
+#
+
+#
+# Some wireless drivers require a rate control algorithm
+#
+# CONFIG_WIMAX is not set
+CONFIG_RFKILL=y
+# CONFIG_RFKILL_PM is not set
+# CONFIG_RFKILL_INPUT is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AFS_PARTS is not set
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND is not set
+CONFIG_MTD_RKNAND=y
+CONFIG_MTD_NAND_RK29XX=y
+CONFIG_MTD_RKNAND_BUFFER=y
+# CONFIG_MTD_EMMC_CLK_POWER_SAVE is not set
+# CONFIG_MTD_NAND_RK29XX_DEBUG is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_UB is not set
+# CONFIG_BLK_DEV_RAM is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_MG_DISK is not set
+CONFIG_MISC_DEVICES=y
+CONFIG_ANDROID_PMEM=y
+# CONFIG_ICS932S401 is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_KERNEL_DEBUGGER_CORE is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_UID_STAT is not set
+# CONFIG_WL127X_RFKILL is not set
+CONFIG_APANIC=y
+CONFIG_APANIC_PLABEL="kpanic"
+# CONFIG_STE is not set
+# CONFIG_MTK23D is not set
+CONFIG_TDSC8800=y
+# CONFIG_FM580X is not set
+# CONFIG_MU509 is not set
+# CONFIG_RK29_NEWTON is not set
+CONFIG_RK29_SC8800=y
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_RK29_SUPPORT_MODEM is not set
+CONFIG_RK29_GPS=y
+CONFIG_GPS_GNS7560=y
+
+#
+# Motion Sensors Support
+#
+# CONFIG_MPU_NONE is not set
+# CONFIG_MPU_SENSORS_MPU3050 is not set
+# CONFIG_MPU_SENSORS_MPU6000 is not set
+# CONFIG_MPU_SENSORS_TIMERIRQ is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+CONFIG_SCSI_LOWLEVEL=y
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_LIBFC is not set
+# CONFIG_LIBFCOE is not set
+# CONFIG_SCSI_DEBUG is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+# CONFIG_ATA is not set
+CONFIG_MD=y
+# CONFIG_BLK_DEV_MD is not set
+CONFIG_BLK_DEV_DM=y
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=y
+# CONFIG_DM_SNAPSHOT is not set
+# CONFIG_DM_MIRROR is not set
+# CONFIG_DM_ZERO is not set
+# CONFIG_DM_MULTIPATH is not set
+# CONFIG_DM_DELAY is not set
+CONFIG_DM_UEVENT=y
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_AX88796 is not set
+# CONFIG_RK29_VMAC is not set
+# CONFIG_SMC91X is not set
+# CONFIG_DM9000 is not set
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_SMC911X is not set
+# CONFIG_SMSC911X is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+CONFIG_WLAN_80211=y
+# CONFIG_WIFI_NONE is not set
+CONFIG_BCM4329=y
+# CONFIG_MV8686 is not set
+# CONFIG_BCM4319 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+# CONFIG_USB_HSO is not set
+# CONFIG_WAN is not set
+CONFIG_PPP=y
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=y
+CONFIG_PPP_SYNC_TTY=y
+CONFIG_PPP_DEFLATE=y
+CONFIG_PPP_BSDCOMP=y
+# CONFIG_PPP_MPPE is not set
+# CONFIG_PPPOE is not set
+# CONFIG_PPPOL2TP is not set
+# CONFIG_PPPOLAC is not set
+# CONFIG_PPPOPNS is not set
+# CONFIG_SLIP is not set
+CONFIG_SLHC=y
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+CONFIG_INPUT_POLLDEV=y
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+CONFIG_INPUT_KEYRESET=y
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYS_RK29=y
+# CONFIG_SYNAPTICS_SO340010 is not set
+# CONFIG_KEYBOARD_ADP5588 is not set
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_QT2160 is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_GPIO is not set
+# CONFIG_KEYBOARD_WM831X_GPIO is not set
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_XPT2046_SPI is not set
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_ILI2102_IIC is not set
+# CONFIG_TOUCHSCREEN_IT7250 is not set
+# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
+# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
+# CONFIG_TOUCHSCREEN_FUJITSU is not set
+# CONFIG_TOUCHSCREEN_GUNZE is not set
+# CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_MCS5000 is not set
+# CONFIG_TOUCHSCREEN_MTOUCH is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
+# CONFIG_TOUCHSCREEN_MK712 is not set
+# CONFIG_TOUCHSCREEN_PENMOUNT is not set
+# CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI is not set
+# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
+# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
+# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_W90X900 is not set
+# CONFIG_HANNSTAR_P1003 is not set
+# CONFIG_ATMEL_MXT224 is not set
+# CONFIG_SINTEK_3FA16 is not set
+# CONFIG_EETI_EGALAX is not set
+# CONFIG_TOUCHSCREEN_IT7260 is not set
+# CONFIG_TOUCHSCREEN_NAS is not set
+# CONFIG_LAIBAO_TS is not set
+# CONFIG_TOUCHSCREEN_GT801_IIC is not set
+# CONFIG_TOUCHSCREEN_GT818_IIC is not set
+CONFIG_TOUCHSCREEN_PIXCIR=y
+# CONFIG_TOUCHSCREEN_FT5X0X is not set
+# CONFIG_D70_L3188A is not set
+# CONFIG_TOUCHSCREEN_GT819 is not set
+# CONFIG_TOUCHSCREEN_FT5406 is not set
+CONFIG_INPUT_MISC=y
+# CONFIG_INPUT_LPSENSOR_ISL29028 is not set
+# CONFIG_INPUT_LPSENSOR_CM3602 is not set
+# CONFIG_INPUT_LPSENSOR_AL3006 is not set
+# CONFIG_INPUT_ATI_REMOTE is not set
+# CONFIG_INPUT_ATI_REMOTE2 is not set
+# CONFIG_INPUT_KEYCHORD is not set
+# CONFIG_INPUT_KEYSPAN_REMOTE is not set
+# CONFIG_INPUT_POWERMATE is not set
+# CONFIG_INPUT_YEALINK is not set
+# CONFIG_INPUT_CM109 is not set
+CONFIG_INPUT_UINPUT=y
+# CONFIG_INPUT_GPIO is not set
+# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
+CONFIG_INPUT_WM831X_ON=y
+CONFIG_MAG_SENSORS=y
+CONFIG_COMPASS_AK8975=y
+# CONFIG_COMPASS_AK8973 is not set
+# CONFIG_COMPASS_MMC328X is not set
+CONFIG_G_SENSOR_DEVICE=y
+# CONFIG_GS_MMA7660 is not set
+# CONFIG_GS_MMA8452 is not set
+CONFIG_GS_BMA023=y
+# CONFIG_GS_L3G4200D is not set
+# CONFIG_INPUT_JOGBALL is not set
+# CONFIG_LIGHT_SENSOR_DEVICE is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+# CONFIG_CONSOLE_TRANSLATIONS is not set
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_DEVMEM=y
+CONFIG_DEVKMEM=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_MAX3100 is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_RK29=y
+CONFIG_SERIAL_RK29_STANDARD=y
+CONFIG_UART0_RK29=y
+CONFIG_UART0_CTS_RTS_RK29=y
+# CONFIG_UART0_DMA_RK29 is not set
+CONFIG_UART1_RK29=y
+CONFIG_UART2_RK29=y
+CONFIG_UART2_CTS_RTS_RK29=y
+# CONFIG_UART2_DMA_RK29 is not set
+CONFIG_UART3_RK29=y
+# CONFIG_UART3_CTS_RTS_RK29 is not set
+# CONFIG_UART3_DMA_RK29 is not set
+CONFIG_SERIAL_RK29_CONSOLE=y
+# CONFIG_SERIAL_SC8800 is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+# CONFIG_DCC_TTY is not set
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+# CONFIG_I2C_CHARDEV is not set
+CONFIG_I2C_HELPER_AUTO=y
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_RK29=y
+
+#
+# Now, there are four I2C interfaces selected by developer.
+#
+CONFIG_I2C0_RK29=y
+CONFIG_RK29_I2C0_CONTROLLER=y
+# CONFIG_RK29_I2C0_GPIO is not set
+CONFIG_I2C1_RK29=y
+CONFIG_RK29_I2C1_CONTROLLER=y
+# CONFIG_RK29_I2C1_GPIO is not set
+CONFIG_I2C2_RK29=y
+CONFIG_RK29_I2C2_CONTROLLER=y
+# CONFIG_RK29_I2C2_GPIO is not set
+CONFIG_I2C3_RK29=y
+CONFIG_RK29_I2C3_CONTROLLER=y
+# CONFIG_RK29_I2C3_GPIO is not set
+# CONFIG_I2C_DEV_RK29 is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_SENSORS_PCA963X is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+CONFIG_SPIM_RK29=y
+CONFIG_SPIM0_RK29=y
+CONFIG_SPIM1_RK29=y
+CONFIG_LCD_USE_SPIM_CONTROL=y
+# CONFIG_LCD_USE_SPI0 is not set
+CONFIG_LCD_USE_SPI1=y
+
+#
+# SPI Protocol Masters
+#
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_TLE62X0 is not set
+CONFIG_ADC=y
+# CONFIG_ADC_RK28 is not set
+CONFIG_ADC_RK29=y
+
+#
+# Headset device support
+#
+CONFIG_RK_HEADSET_DET=y
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+# CONFIG_GPIO_SYSFS is not set
+
+#
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+CONFIG_GPIO_WM831X=y
+CONFIG_GPIO_WM8994=y
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
+# CONFIG_GPIO_PCA9554 is not set
+# CONFIG_IOEXTEND_TCA6424 is not set
+CONFIG_EXPANDED_GPIO_NUM=0
+CONFIG_EXPANDED_GPIO_IRQ_NUM=0
+# CONFIG_EXPAND_GPIO_SOFT_INTERRUPT is not set
+CONFIG_SPI_FPGA_GPIO_NUM=96
+CONFIG_SPI_FPGA_GPIO_IRQ_NUM=16
+# CONFIG_W1 is not set
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+# CONFIG_PDA_POWER is not set
+CONFIG_WM831X_BACKUP=y
+CONFIG_WM831X_POWER=y
+CONFIG_WM831X_CHARGER_DISPLAY=y
+# CONFIG_WM831X_WITH_BATTERY is not set
+# CONFIG_BATTERY_DS2760 is not set
+# CONFIG_BATTERY_DS2782 is not set
+# CONFIG_BATTERY_BQ27x00 is not set
+# CONFIG_BATTERY_MAX17040 is not set
+# CONFIG_BATTERY_STC3100 is not set
+# CONFIG_BATTERY_BQ27510 is not set
+# CONFIG_BATTERY_BQ27541 is not set
+# CONFIG_BATTERY_BQ3060 is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_CORE=y
+# CONFIG_MFD_SM501 is not set
+# CONFIG_MFD_ASIC3 is not set
+# CONFIG_HTC_EGPIO is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_TPS65910_CORE is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_T7L66XB is not set
+# CONFIG_MFD_TC6387XB is not set
+# CONFIG_MFD_TC6393XB is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_MFD_WM8400 is not set
+CONFIG_MFD_WM831X=y
+CONFIG_MFD_WM831X_I2C=y
+CONFIG_MFD_WM8994=y
+# CONFIG_MFD_WM831X_SPI is not set
+# CONFIG_MFD_WM831X_SPI_A22 is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+CONFIG_REGULATOR=y
+# CONFIG_REGULATOR_DEBUG is not set
+# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
+# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
+# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set
+# CONFIG_REGULATOR_BQ24022 is not set
+# CONFIG_REGULATOR_MAX1586 is not set
+CONFIG_REGULATOR_WM831X=y
+CONFIG_REGULATOR_WM8994=y
+# CONFIG_REGULATOR_LP3971 is not set
+# CONFIG_REGULATOR_TPS65023 is not set
+# CONFIG_REGULATOR_TPS6507X is not set
+# CONFIG_RK2818_REGULATOR_CHARGE is not set
+# CONFIG_RK2818_REGULATOR_LP8725 is not set
+# CONFIG_RK29_PWM_REGULATOR is not set
+CONFIG_MEDIA_SUPPORT=y
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_V4L2_COMMON=y
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+# CONFIG_DVB_CORE is not set
+CONFIG_VIDEO_MEDIA=y
+
+#
+# Multimedia drivers
+#
+# CONFIG_MEDIA_ATTACH is not set
+CONFIG_MEDIA_TUNER=y
+# CONFIG_MEDIA_TUNER_CUSTOMISE is not set
+CONFIG_MEDIA_TUNER_SIMPLE=y
+CONFIG_MEDIA_TUNER_TDA8290=y
+CONFIG_MEDIA_TUNER_TDA9887=y
+CONFIG_MEDIA_TUNER_TEA5761=y
+CONFIG_MEDIA_TUNER_TEA5767=y
+CONFIG_MEDIA_TUNER_MT20XX=y
+CONFIG_MEDIA_TUNER_XC2028=y
+CONFIG_MEDIA_TUNER_XC5000=y
+CONFIG_MEDIA_TUNER_MC44S803=y
+CONFIG_VIDEO_V4L2=y
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEOBUF_GEN=y
+CONFIG_VIDEOBUF_DMA_CONTIG=y
+# CONFIG_VIDEO_RK29XX_VOUT is not set
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
+# CONFIG_VIDEO_CPIA is not set
+# CONFIG_VIDEO_CPIA2 is not set
+# CONFIG_VIDEO_SAA5246A is not set
+# CONFIG_VIDEO_SAA5249 is not set
+CONFIG_SOC_CAMERA=y
+# CONFIG_SOC_CAMERA_MT9M001 is not set
+# CONFIG_SOC_CAMERA_MT9M111 is not set
+# CONFIG_SOC_CAMERA_MT9M112 is not set
+# CONFIG_SOC_CAMERA_MT9T031 is not set
+# CONFIG_SOC_CAMERA_MT9T111 is not set
+# CONFIG_SOC_CAMERA_MT9P111 is not set
+# CONFIG_SOC_CAMERA_MT9D112 is not set
+# CONFIG_SOC_CAMERA_MT9D113 is not set
+# CONFIG_SOC_CAMERA_MT9V022 is not set
+# CONFIG_SOC_CAMERA_TW9910 is not set
+# CONFIG_SOC_CAMERA_PLATFORM is not set
+# CONFIG_SOC_CAMERA_OV772X is not set
+# CONFIG_SOC_CAMERA_OV7675 is not set
+# CONFIG_SOC_CAMERA_OV2655 is not set
+# CONFIG_SOC_CAMERA_OV2659 is not set
+# CONFIG_SOC_CAMERA_OV9650 is not set
+# CONFIG_SOC_CAMERA_OV2640 is not set
+# CONFIG_SOC_CAMERA_OV3640 is not set
+# CONFIG_SOC_CAMERA_OV5642 is not set
+CONFIG_SOC_CAMERA_OV5640=y
+CONFIG_OV5640_AUTOFOCUS=y
+# CONFIG_OV5640_FIXEDFOCUS is not set
+# CONFIG_SOC_CAMERA_S5K6AA is not set
+# CONFIG_SOC_CAMERA_GT2005 is not set
+# CONFIG_SOC_CAMERA_GC0307 is not set
+# CONFIG_SOC_CAMERA_GC0308 is not set
+CONFIG_SOC_CAMERA_GC0309=y
+# CONFIG_SOC_CAMERA_GC2015 is not set
+# CONFIG_SOC_CAMERA_HI253 is not set
+# CONFIG_SOC_CAMERA_HI704 is not set
+# CONFIG_SOC_CAMERA_SIV120B is not set
+# CONFIG_SOC_CAMERA_SID130B is not set
+# CONFIG_SOC_CAMERA_NT99250 is not set
+# CONFIG_VIDEO_SH_MOBILE_CEU is not set
+CONFIG_VIDEO_RK29=y
+CONFIG_VIDEO_RK29_WORK_ONEFRAME=y
+# CONFIG_VIDEO_RK29_WORK_PINGPONG is not set
+CONFIG_VIDEO_RK29_WORK_IPP=y
+# CONFIG_VIDEO_RK29_WORK_NOT_IPP is not set
+CONFIG_V4L_USB_DRIVERS=y
+# CONFIG_USB_VIDEO_CLASS is not set
+CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
+CONFIG_USB_GSPCA=m
+# CONFIG_USB_M5602 is not set
+# CONFIG_USB_STV06XX is not set
+# CONFIG_USB_GL860 is not set
+# CONFIG_USB_GSPCA_CONEX is not set
+# CONFIG_USB_GSPCA_ETOMS is not set
+# CONFIG_USB_GSPCA_FINEPIX is not set
+# CONFIG_USB_GSPCA_JEILINJ is not set
+# CONFIG_USB_GSPCA_MARS is not set
+# CONFIG_USB_GSPCA_MR97310A is not set
+# CONFIG_USB_GSPCA_OV519 is not set
+# CONFIG_USB_GSPCA_OV534 is not set
+# CONFIG_USB_GSPCA_PAC207 is not set
+# CONFIG_USB_GSPCA_PAC7311 is not set
+# CONFIG_USB_GSPCA_SN9C20X is not set
+# CONFIG_USB_GSPCA_SONIXB is not set
+# CONFIG_USB_GSPCA_SONIXJ is not set
+# CONFIG_USB_GSPCA_SPCA500 is not set
+# CONFIG_USB_GSPCA_SPCA501 is not set
+# CONFIG_USB_GSPCA_SPCA505 is not set
+# CONFIG_USB_GSPCA_SPCA506 is not set
+# CONFIG_USB_GSPCA_SPCA508 is not set
+# CONFIG_USB_GSPCA_SPCA561 is not set
+# CONFIG_USB_GSPCA_SQ905 is not set
+# CONFIG_USB_GSPCA_SQ905C is not set
+# CONFIG_USB_GSPCA_STK014 is not set
+# CONFIG_USB_GSPCA_SUNPLUS is not set
+# CONFIG_USB_GSPCA_T613 is not set
+# CONFIG_USB_GSPCA_TV8532 is not set
+# CONFIG_USB_GSPCA_VC032X is not set
+# CONFIG_USB_GSPCA_ZC3XX is not set
+# CONFIG_VIDEO_PVRUSB2 is not set
+# CONFIG_VIDEO_HDPVR is not set
+# CONFIG_VIDEO_EM28XX is not set
+# CONFIG_VIDEO_CX231XX is not set
+# CONFIG_VIDEO_USBVISION is not set
+# CONFIG_USB_VICAM is not set
+# CONFIG_USB_IBMCAM is not set
+# CONFIG_USB_KONICAWC is not set
+# CONFIG_USB_QUICKCAM_MESSENGER is not set
+# CONFIG_USB_ET61X251 is not set
+# CONFIG_VIDEO_OVCAMCHIP is not set
+# CONFIG_USB_OV511 is not set
+# CONFIG_USB_SE401 is not set
+# CONFIG_USB_SN9C102 is not set
+# CONFIG_USB_STV680 is not set
+# CONFIG_USB_ZC0301 is not set
+# CONFIG_USB_PWC is not set
+CONFIG_USB_PWC_INPUT_EVDEV=y
+# CONFIG_USB_ZR364XX is not set
+# CONFIG_USB_STKWEBCAM is not set
+# CONFIG_USB_S2255 is not set
+CONFIG_RADIO_ADAPTERS=y
+# CONFIG_I2C_SI4713 is not set
+# CONFIG_RADIO_SI4713 is not set
+# CONFIG_USB_DSBR is not set
+# CONFIG_RADIO_SI470X is not set
+# CONFIG_USB_MR800 is not set
+# CONFIG_RADIO_TEA5764 is not set
+CONFIG_SMS_SIANO_MDTV=m
+# CONFIG_DAB is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_TMIO is not set
+# CONFIG_FB_RK2818 is not set
+CONFIG_FB_RK29=y
+CONFIG_FB_WORK_IPP=y
+# CONFIG_FB_SCALING_OSD is not set
+CONFIG_FB_ROTATE_VIDEO=y
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+# CONFIG_BACKLIGHT_GENERIC is not set
+CONFIG_BACKLIGHT_WM831X=y
+# CONFIG_BACKLIGHT_RK29_BL is not set
+# CONFIG_FIH_TOUCHKEY_LED is not set
+# CONFIG_BACKLIGHT_AW9364 is not set
+CONFIG_BUTTON_LIGHT=y
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=y
+
+#
+# Display hardware drivers
+#
+# CONFIG_LCD_NULL is not set
+# CONFIG_LCD_TD043MGEA1 is not set
+# CONFIG_LCD_HX8357 is not set
+# CONFIG_LCD_TJ048NC01CA is not set
+# CONFIG_LCD_HL070VM4AU is not set
+# CONFIG_LCD_HSD070IDW1 is not set
+# CONFIG_LCD_RGB_TFT480800_25_E is not set
+# CONFIG_LCD_HSD100PXN is not set
+# CONFIG_LCD_HSD07PFW1 is not set
+# CONFIG_LCD_BYD8688FTGF is not set
+# CONFIG_LCD_B101AW06 is not set
+# CONFIG_LCD_LS035Y8DX02A is not set
+CONFIG_LCD_LS035Y8DX04A=y
+# CONFIG_LCD_CPTCLAA038LA31XE is not set
+# CONFIG_LCD_A060SE02 is not set
+# CONFIG_LCD_S1D13521 is not set
+# CONFIG_LCD_NT35582 is not set
+# CONFIG_LCD_NT35580 is not set
+# CONFIG_LCD_IPS1P5680_V1_E is not set
+# CONFIG_LCD_MCU_TFT480800_25_E is not set
+# CONFIG_LCD_NT35510 is not set
+# CONFIG_LCD_ILI9803_CPT4_3 is not set
+# CONFIG_DEFAULT_OUT_HDMI is not set
+# CONFIG_LCD_AT070TNA2 is not set
+# CONFIG_LCD_AT070TN93 is not set
+
+#
+# HDMI
+#
+# CONFIG_HDMI is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_LOGO_CHARGER_CLUT224=y
+CONFIG_SOUND=y
+# CONFIG_SOUND_OSS_CORE is not set
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_JACK=y
+# CONFIG_SND_SEQUENCER is not set
+# CONFIG_SND_MIXER_OSS is not set
+# CONFIG_SND_PCM_OSS is not set
+# CONFIG_SND_HRTIMER is not set
+# CONFIG_SND_DYNAMIC_MINORS is not set
+# CONFIG_SND_SUPPORT_OLD_API is not set
+# CONFIG_SND_VERBOSE_PROCFS is not set
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+# CONFIG_SND_DRIVERS is not set
+# CONFIG_SND_ARM is not set
+# CONFIG_SND_SPI is not set
+# CONFIG_SND_USB is not set
+CONFIG_SND_SOC=y
+CONFIG_SND_RK29_SOC=y
+CONFIG_SND_RK29_SOC_I2S=y
+# CONFIG_SND_RK29_SOC_I2S_2CH is not set
+CONFIG_SND_RK29_SOC_I2S_8CH=y
+# CONFIG_SND_I2S_DMA_EVENT_DYNAMIC is not set
+CONFIG_SND_I2S_DMA_EVENT_STATIC=y
+# CONFIG_SND_RK29_SOC_WM8988 is not set
+# CONFIG_SND_RK29_SOC_WM8900 is not set
+# CONFIG_SND_RK29_SOC_alc5621 is not set
+# CONFIG_SND_RK29_SOC_alc5631 is not set
+# CONFIG_SND_RK29_SOC_RT5625 is not set
+CONFIG_SND_RK29_SOC_WM8994=y
+# CONFIG_SND_RK29_SOC_CS42L52 is not set
+# CONFIG_SND_RK29_CODEC_SOC_MASTER is not set
+CONFIG_SND_RK29_CODEC_SOC_SLAVE=y
+CONFIG_SND_SOC_I2C_AND_SPI=y
+# CONFIG_SND_SOC_ALL_CODECS is not set
+CONFIG_SND_SOC_WM8994=y
+# CONFIG_SOUND_PRIME is not set
+# CONFIG_HID_SUPPORT is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+# CONFIG_USB_DEVICEFS is not set
+CONFIG_USB_DEVICE_CLASS=y
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+CONFIG_USB_OTG_BLACKLIST_HUB=y
+# CONFIG_USB_MON is not set
+# CONFIG_USB_WUSB is not set
+# CONFIG_USB_WUSB_CBAF is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_OXU210HP_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1760_HCD is not set
+# CONFIG_USB_ISP1362_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
+# CONFIG_USB_HWA_HCD is not set
+# CONFIG_USB_MUSB_HDRC is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+# CONFIG_USB_WDM is not set
+# CONFIG_USB_TMC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+
+#
+# also be needed; see USB_STORAGE Help for more info
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_ONETOUCH is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB port drivers
+#
+CONFIG_USB_SERIAL=y
+# CONFIG_USB_SERIAL_CONSOLE is not set
+# CONFIG_USB_EZUSB is not set
+CONFIG_USB_SERIAL_GENERIC=y
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+# CONFIG_USB_SERIAL_ARK3116 is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_CH341 is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_CP210X is not set
+# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_FUNSOFT is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_GARMIN is not set
+# CONFIG_USB_SERIAL_IPW is not set
+# CONFIG_USB_SERIAL_IUU is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_MOS7720 is not set
+# CONFIG_USB_SERIAL_MOS7840 is not set
+# CONFIG_USB_SERIAL_MOTOROLA is not set
+# CONFIG_USB_SERIAL_NAVMAN is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_OTI6858 is not set
+# CONFIG_USB_SERIAL_QUALCOMM is not set
+# CONFIG_USB_SERIAL_SPCP8X5 is not set
+# CONFIG_USB_SERIAL_HP4X is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
+# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
+# CONFIG_USB_SERIAL_SYMBOL is not set
+# CONFIG_USB_SERIAL_TI is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_XIRCOM is not set
+CONFIG_USB_SERIAL_OPTION=y
+# CONFIG_USB_SERIAL_OMNINET is not set
+# CONFIG_USB_SERIAL_OPTICON is not set
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_SEVSEG is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_VST is not set
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG is not set
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
+CONFIG_USB_GADGET_DWC_OTG=y
+CONFIG_USB_DWC_OTG=y
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+# CONFIG_USB_ETH is not set
+# CONFIG_USB_GADGETFS is not set
+# CONFIG_USB_FILE_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+CONFIG_USB_ANDROID=y
+# CONFIG_USB_ANDROID_ACM is not set
+CONFIG_USB_ANDROID_ADB=y
+CONFIG_USB_ANDROID_MASS_STORAGE=y
+# CONFIG_USB_ANDROID_RNDIS is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_USB11_HOST is not set
+# CONFIG_USB20_HOST is not set
+CONFIG_USB20_OTG=y
+# CONFIG_DWC_OTG_HOST_ONLY is not set
+CONFIG_DWC_OTG_DEVICE_ONLY=y
+# CONFIG_DWC_OTG_BOTH_HOST_SLAVE is not set
+CONFIG_DWC_CONN_EN=y
+# CONFIG_DWC_OTG_DEBUG is not set
+# CONFIG_DWC_REMOTE_WAKEUP is not set
+CONFIG_DWC_OTG=y
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_UNSAFE_RESUME=y
+CONFIG_MMC_EMBEDDED_SDIO=y
+CONFIG_MMC_PARANOID_SD_INIT=y
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_MMC_BLOCK_DEFERRED_RESUME is not set
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+CONFIG_SDMMC_RK29=y
+
+#
+# Now, there are two SDMMC controllers selected, SDMMC0 and SDMMC1.
+#
+# CONFIG_SDMMC_RK29_OLD=y
+CONFIG_SDMMC0_RK29=y
+CONFIG_SDMMC1_RK29=y
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
+# CONFIG_MMC_ATMELMCI is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+CONFIG_SWITCH=y
+CONFIG_SWITCH_GPIO=y
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+CONFIG_RTC_INTF_ALARM=y
+CONFIG_RTC_INTF_ALARM_DEV=y
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_HYM8563 is not set
+# CONFIG_RTC_M41T66 is not set
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_S35392A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
+# CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_CMOS is not set
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+CONFIG_RTC_DRV_WM831X=y
+
+#
+# on-CPU RTC drivers
+#
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+CONFIG_STAGING=y
+# CONFIG_STAGING_EXCLUDE_BUILD is not set
+# CONFIG_USB_IP_COMMON is not set
+# CONFIG_PRISM2_USB is not set
+# CONFIG_ECHO is not set
+# CONFIG_COMEDI is not set
+# CONFIG_ASUS_OLED is not set
+# CONFIG_TRANZPORT is not set
+
+#
+# Android
+#
+CONFIG_ANDROID=y
+CONFIG_ANDROID_BINDER_IPC=y
+CONFIG_ANDROID_LOGGER=y
+CONFIG_ANDROID_RAM_CONSOLE=y
+CONFIG_ANDROID_RAM_CONSOLE_ENABLE_VERBOSE=y
+CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION=y
+CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_DATA_SIZE=128
+CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_ECC_SIZE=16
+CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_SYMBOL_SIZE=8
+CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION_POLYNOMIAL=0x11d
+# CONFIG_ANDROID_RAM_CONSOLE_EARLY_INIT is not set
+CONFIG_ANDROID_TIMED_OUTPUT=y
+CONFIG_ANDROID_TIMED_GPIO=y
+CONFIG_ANDROID_LOW_MEMORY_KILLER=y
+# CONFIG_DST is not set
+# CONFIG_POHMELFS is not set
+# CONFIG_PLAN9AUTH is not set
+# CONFIG_LINE6_USB is not set
+# CONFIG_USB_SERIAL_QUATECH2 is not set
+# CONFIG_USB_SERIAL_QUATECH_USB2 is not set
+# CONFIG_VT6656 is not set
+# CONFIG_FB_UDL is not set
+
+#
+# RAR Register Driver
+#
+# CONFIG_RAR_REGISTER is not set
+# CONFIG_IIO is not set
+
+#
+# GPU Vivante
+#
+CONFIG_VIVANTE=y
+
+#
+# IPP
+#
+CONFIG_RK29_IPP=y
+# CONFIG_DEINTERLACE is not set
+
+#
+# CMMB
+#
+CONFIG_CMMB=y
+CONFIG_SMS_HOSTLIB_SUBSYS=y
+CONFIG_SMS_SPI_ROCKCHIP=y
+# CONFIG_TEST_CODE is not set
+# CONFIG_RK29_SMC is not set
+
+#
+# CIR support
+#
+# CONFIG_RK_CIR is not set
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
+# CONFIG_EXT3_FS_XATTR is not set
+CONFIG_EXT4_FS=y
+# CONFIG_EXT4_FS_XATTR is not set
+# CONFIG_EXT4_DEBUG is not set
+CONFIG_JBD=y
+CONFIG_JBD2=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+# CONFIG_DNOTIFY is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=y
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_YAFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+CONFIG_CRAMFS=y
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_NETWORK_FILESYSTEMS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=y
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+CONFIG_NLS_CODEPAGE_936=y
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+CONFIG_NLS_ISO8859_15=y
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=y
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+# CONFIG_SCHED_DEBUG is not set
+CONFIG_SCHEDSTATS=y
+CONFIG_TIMER_STATS=y
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KMEMLEAK is not set
+# CONFIG_DEBUG_PREEMPT is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_HIGHMEM is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+CONFIG_ARM_UNWIND=y
+# CONFIG_DEBUG_USER is not set
+CONFIG_DEBUG_ERRORS=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_LL is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=y
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+CONFIG_CRYPTO_TWOFISH=y
+CONFIG_CRYPTO_TWOFISH_COMMON=y
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=y
+CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_REED_SOLOMON=y
+CONFIG_REED_SOLOMON_ENC8=y
+CONFIG_REED_SOLOMON_DEC8=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 54ebef33ef3999269b04abeca78e1429ce1d9055..22fa6e1aa384379c99bed6dc8c175c41c95fd936 100644 (file)
@@ -53,6 +53,12 @@ config MACH_RK29_A22
         help
          Support for the ROCKCHIP Board For A22.
 
+config MACH_RK29_TD8801_V2
+       depends on ARCH_RK29
+       bool "ROCKCHIP Board Rk29 For TD8801_v2"
+        help
+         Support for the ROCKCHIP Board For TD8801_v2.
+
 config MACH_RK29_PHONEPADSDK
        depends on ARCH_RK29
        bool "ROCKCHIP Board Rk29 For Phone Pad Sdk"
index d56c1f037d77347246e40f4a784af1b548d5dac4..ad27049352af942dcefd2c5aecee9c3379d8669f 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_MACH_RK29_MALATA) += board-malata.o board-rk29malata-key.o board-rk
 obj-$(CONFIG_MACH_RK29_PHONESDK) += board-rk29-phonesdk.o board-rk29-phonesdk-key.o board-rk29-phonesdk-rfkill.o
 obj-$(CONFIG_MACH_RK29FIH) += board-rk29-fih.o board-rk29-fih-key.o board-rk29sdk-rfkill.o board-rk29sdk-power.o
 obj-$(CONFIG_MACH_RK29_A22) += board-rk29-a22.o board-rk29-a22-key.o board-rk29-a22-rfkill.o
+obj-$(CONFIG_MACH_RK29_TD8801_V2) += board-rk29-td8801_v2.o board-rk29-td8801_v2-key.o board-rk29-td8801_v2-rfkill.o
 obj-$(CONFIG_MACH_RK29_PHONEPADSDK) += board-rk29phonepadsdk.o board-rk29phonepadsdk-key.o board-rk29phonepadsdk-rfkill.o board-rk29phonepadsdk-power.o
 obj-$(CONFIG_MACH_RK29_newton) += board-rk29-newton.o board-rk29-newton-key.o board-newton-rfkill.o board-rk29sdk-power.o
 obj-$(CONFIG_MACH_RK29_K97) += board-rk29-k97.o board-rk29k97-key.o board-rk29sdk-rfkill.o board-rk29sdk-power.o
index a87b2b7ad6bc1b4fa42e821eb682e7f1bf4cc872..92d399baaeb4508b881705b6d36473ebdddca629 100755 (executable)
@@ -1411,14 +1411,14 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .flags                  = 0,
        },
 #endif
-#if defined (CONFIG_SND_SOC_alc5621)
+#if defined (CONFIG_SND_SOC_RT5621)
         {
-                .type                   = "ALC5621",
+                .type                   = "rt5621",
                 .addr                   = 0x1a,
                 .flags                  = 0,
         },
 #endif
-#if defined (CONFIG_SND_SOC_alc5631)
+#if defined (CONFIG_SND_SOC_RT5631)
         {
                 .type                   = "rt5631",
                 .addr                   = 0x1a,
@@ -1432,6 +1432,13 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .flags                  = 0,
        },
 #endif
+#if defined (CONFIG_SND_SOC_WM8988)
+       {
+               .type                   = "wm8988",
+               .addr           = 0x1A,
+               .flags                  = 0,
+       },
+#endif
 #if defined (CONFIG_SND_SOC_WM8900)
        {
                .type                   = "wm8900",
index c99bfebec354bac7020b79232737cd386c14f136..58509d2542537c0ca690cf8713494610a11d29e0 100755 (executable)
@@ -1449,9 +1449,9 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .flags                  = 0,
        },
 #endif
-#if defined (CONFIG_SND_SOC_alc5621)
+#if defined (CONFIG_SND_SOC_RT5621)
         {
-                .type                   = "ALC5621",
+                .type                   = "rt5621",
                 .addr                   = 0x1a,
                 .flags                  = 0,
         },
index d48114edc9bdd067e15024a5a5099a101e8b488f..ee8dcbfa7a1f306353ba2245f96cdb6ff75e7faa 100755 (executable)
@@ -51,8 +51,6 @@
 #include <linux/mfd/wm831x/pdata.h>
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/gpio.h>
-#include <linux/mfd/wm8994/pdata.h>
-#include <linux/mfd/wm8994/registers.h>
 
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
@@ -1696,35 +1694,6 @@ struct platform_device rk29_device_gps = {
        };
 #endif
 
-/*****************************************************************************************
- * wm8994  codec
- * author: qjb@rock-chips.com
- *****************************************************************************************/
-struct wm8994_pdata wm8994_platdata = {        
-
-       .BB_input_diff = 0,
-       .BB_class = NO_PCM_BB,
-       
-       .no_earpiece = 0,
-       .sp_hp_same_channel = 0,
-       
-       .PA_control_pin = 0,    
-       .Power_EN_Pin = RK29_PIN5_PA1,
-
-       .speaker_incall_vol = 0,
-       .speaker_incall_mic_vol = -9,
-       .speaker_normal_vol = 6,
-       .earpiece_incall_vol = 0,
-       .headset_incall_vol = 6,
-       .headset_incall_mic_vol = -6,
-       .headset_normal_vol = -6,
-       .BT_incall_vol = 0,
-       .BT_incall_mic_vol = 0,
-       .recorder_vol = 30,
-       
-};
-
-
 #ifdef CONFIG_RK_HEADSET_DET
 #define HEADSET_GPIO RK29_PIN4_PD2
 struct rk_headset_pdata rk_headset_info = {
@@ -1935,9 +1904,6 @@ static struct i2c_board_info __initdata board_i2c0_devices[] = {
                .type                   = "wm8994",
                .addr           = 0x1a,
                .flags                  = 0,
-//     #if defined(CONFIG_MFD_WM8994)  
-               .platform_data  = &wm8994_platdata,     
-//     #endif  
        },
 #endif
 #if defined (CONFIG_BATTERY_STC3100)
@@ -2623,7 +2589,9 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = {
                                   MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
        .io_init = rk29_sdmmc1_cfg_gpio,
        .dma_name = "sdio",
+#if !defined(CONFIG_SDMMC_RK29_OLD)
        .set_iomux = rk29_sdmmc_set_iomux,
+#endif
 #ifdef CONFIG_SDMMC1_USE_DMA
        .use_dma  = 1,
 #else
diff --git a/arch/arm/mach-rk29/board-rk29-td8801_v2-key.c b/arch/arm/mach-rk29/board-rk29-td8801_v2-key.c
new file mode 100644 (file)
index 0000000..e5bc314
--- /dev/null
@@ -0,0 +1,105 @@
+#include <mach/key.h>
+#include <mach/gpio.h>
+
+#define EV_ENCALL                              KEY_F4
+#define EV_MENU                                        KEY_F1
+
+#define PRESS_LEV_LOW                  1
+#define PRESS_LEV_HIGH                 0
+
+static struct rk29_keys_button key_button[] = {
+       {
+               .desc   = "menu",
+               .code   = EV_MENU,
+               .gpio   = RK29_PIN6_PA0,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "vol+",
+               .code   = KEY_VOLUMEUP,
+               .gpio   = RK29_PIN6_PA1,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "vol-",
+               .code   = KEY_VOLUMEDOWN,
+               .gpio   = RK29_PIN6_PA2,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "home",
+               .code   = KEY_HOME,
+               .gpio   = RK29_PIN6_PA3,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "search",
+               .code   = KEY_SEARCH,
+               .gpio   = RK29_PIN6_PA4,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "esc",
+               .code   = KEY_BACK,
+               .gpio   = RK29_PIN6_PA5,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "sensor",
+               .code   = KEY_CAMERA,
+               .gpio   = RK29_PIN6_PA6,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "play",
+               .code   = KEY_POWER,
+               .gpio   = RK29_PIN6_PA7,
+               .active_low = PRESS_LEV_LOW,
+               .wakeup = 1,
+       },
+#if 0
+       {
+               .desc   = "vol+",
+               .code   = KEY_VOLUMEDOWN,
+               .adc_value      = 95,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "vol-",
+               .code   = KEY_VOLUMEUP,
+               .adc_value      = 249,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "menu",
+               .code   = EV_MENU,
+               .adc_value      = 406,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "home",
+               .code   = KEY_HOME,
+               .code_long_press = KEY_F4,
+               .adc_value      = 561,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "esc",
+               .code   = KEY_ESC,
+               .adc_value      = 726,
+               .active_low = PRESS_LEV_LOW,
+       },
+       {
+               .desc   = "adkey6",
+               .code   = KEY_BACK,
+               .code_long_press = EV_ENCALL,
+               .adc_value      = 899,
+               .active_low = PRESS_LEV_LOW,
+       },
+#endif
+};
+struct rk29_keys_platform_data rk29_keys_pdata = {
+       .buttons        = key_button,
+       .nbuttons       = ARRAY_SIZE(key_button),
+       .chn    = -1,  //chn: 0-7, if do not use ADC,set 'chn' -1
+};
diff --git a/arch/arm/mach-rk29/board-rk29-td8801_v2-rfkill.c b/arch/arm/mach-rk29/board-rk29-td8801_v2-rfkill.c
new file mode 100644 (file)
index 0000000..d5a5d01
--- /dev/null
@@ -0,0 +1,313 @@
+/*
+ * Copyright (C) 2010 ROCKCHIP, Inc.
+ * Author: roger_chen <cz@rock-chips.com>
+ *
+ * This program is the bluetooth device bcm4329's driver,
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/rfkill.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/wakelock.h>
+#include <linux/fs.h>
+#include <asm/uaccess.h>
+#include <mach/gpio.h>
+#include <asm/irq.h>
+#include <mach/iomux.h>
+#include <linux/wakelock.h>
+#include <linux/timer.h>
+#include <mach/board.h>
+#if 0
+#define DBG(x...)   printk(KERN_INFO x)
+#else
+#define DBG(x...)
+#endif
+
+#define BT_WAKE_HOST_SUPPORT 1
+
+struct bt_ctrl
+{
+    struct rfkill *bt_rfk;
+#if BT_WAKE_HOST_SUPPORT
+    struct timer_list tl;
+    bool b_HostWake;
+    struct wake_lock bt_wakelock;
+#endif
+};
+
+#define BT_GPIO_POWER           RK29_PIN5_PD6
+#define IOMUX_BT_GPIO_POWER     rk29_mux_api_set(GPIO5D6_SDMMC1PWREN_NAME, GPIO5H_GPIO5D6);
+#define BT_GPIO_RESET                  RK29_PIN6_PC7
+#define BT_GPIO_WAKE_UP         RK29_PIN6_PD0
+#define BT_GPIO_WAKE_UP_HOST    RK29_PIN4_PD4
+#define IOMUX_BT_GPIO_WAKE_UP_HOST() rk29_mux_api_set(GPIO4D4_CPUTRACECLK_NAME,GPIO4H_GPIO4D4);
+
+//bt cts paired to uart rts
+#define UART_RTS                RK29_PIN2_PA7
+#define IOMUX_UART_RTS_GPIO     rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_GPIO2A7);
+#define IOMUX_UART_RTS          rk29_mux_api_set(GPIO2A7_UART2RTSN_NAME, GPIO2L_UART2_RTS_N);
+
+#define BT_WAKE_LOCK_TIMEOUT    10 //s
+
+static const char bt_name[] = "bcm4329";
+extern int rk29sdk_bt_power_state;
+extern int rk29sdk_wifi_power_state;
+
+struct bt_ctrl gBtCtrl;
+
+#if BT_WAKE_HOST_SUPPORT
+void resetBtHostSleepTimer(void)
+{
+    mod_timer(&(gBtCtrl.tl),jiffies + BT_WAKE_LOCK_TIMEOUT*HZ);//ÔÙÖØÐÂÉèÖó¬Ê±Öµ¡£
+}
+
+void btWakeupHostLock(void)
+{
+    if(gBtCtrl.b_HostWake == false){
+        DBG("*************************Lock\n");
+
+        wake_lock(&(gBtCtrl.bt_wakelock));
+        gBtCtrl.b_HostWake = true;
+    }
+}
+
+void btWakeupHostUnlock(void)
+{
+    if(gBtCtrl.b_HostWake == true){
+        DBG("*************************UnLock\n");
+        wake_unlock(&(gBtCtrl.bt_wakelock));  //ÈÃϵͳ˯Ãß
+        gBtCtrl.b_HostWake = false;
+    }
+}
+
+static void timer_hostSleep(unsigned long arg)
+{
+       DBG("%s---b_HostWake=%d\n",__FUNCTION__,gBtCtrl.b_HostWake);
+    btWakeupHostUnlock();
+}
+
+
+#ifdef CONFIG_PM
+static int bcm4329_rfkill_suspend(struct platform_device *pdev, pm_message_t state)
+{
+    DBG("%s\n",__FUNCTION__);
+
+       //To prevent uart to receive bt data when suspended
+       IOMUX_UART_RTS_GPIO;
+       gpio_request(UART_RTS, "uart_rts");
+       gpio_direction_output(UART_RTS, 0);
+       gpio_set_value(UART_RTS, GPIO_HIGH);
+
+    return 0;
+}
+
+static int bcm4329_rfkill_resume(struct platform_device *pdev)
+{
+    DBG("%s\n",__FUNCTION__);
+
+    btWakeupHostLock();
+    resetBtHostSleepTimer();
+
+       gpio_set_value(UART_RTS, GPIO_LOW);
+       IOMUX_UART_RTS;
+
+    return 0;
+}
+#else
+#define bcm4329_rfkill_suspend NULL
+#define bcm4329_rfkill_resume  NULL
+#endif
+
+static irqreturn_t bcm4329_wake_host_irq(int irq, void *dev)
+{
+       DBG("%s\n",__FUNCTION__);
+
+    btWakeupHostLock();
+    resetBtHostSleepTimer();
+       return IRQ_HANDLED;
+}
+#endif
+
+#ifdef CONFIG_BT_HCIBCM4325
+int bcm4325_sleep(int bSleep)
+{
+//     printk("*************bt enter sleep***************\n");
+    if (bSleep)
+    gpio_set_value(BT_GPIO_WAKE_UP, GPIO_LOW);   //low represent bt device may enter sleep
+    else
+    gpio_set_value(BT_GPIO_WAKE_UP, GPIO_HIGH);  //high represent bt device must be awake
+
+       //printk("sleep=%d\n",bSleep);
+}
+#endif
+
+static int bcm4329_set_block(void *data, bool blocked)
+{
+       DBG("%s---blocked :%d\n", __FUNCTION__, blocked);
+
+        IOMUX_BT_GPIO_POWER;
+
+       if (false == blocked) {
+               gpio_set_value(BT_GPIO_POWER, GPIO_HIGH);  /* bt power on */
+                gpio_set_value(BT_GPIO_RESET, GPIO_LOW);
+                mdelay(200);
+               gpio_set_value(BT_GPIO_RESET, GPIO_HIGH);  /* bt reset deactive*/
+               mdelay(200);
+
+#if BT_WAKE_HOST_SUPPORT
+            btWakeupHostLock();
+#endif
+               pr_info("bt turn on power\n");
+       }
+       else {
+#if BT_WAKE_HOST_SUPPORT
+            btWakeupHostUnlock();
+#endif
+               if (!rk29sdk_wifi_power_state) {
+                       gpio_set_value(BT_GPIO_POWER, GPIO_LOW);  /* bt power off */
+               mdelay(20);
+               pr_info("bt shut off power\n");
+               }else {
+                       pr_info("bt shouldn't shut off power, wifi is using it!\n");
+               }
+
+               gpio_set_value(BT_GPIO_RESET, GPIO_LOW);  /* bt reset active*/
+               mdelay(20);
+       }
+
+       rk29sdk_bt_power_state = !blocked;
+       return 0;
+}
+
+
+static const struct rfkill_ops bcm4329_rfk_ops = {
+       .set_block = bcm4329_set_block,
+};
+
+static int __devinit bcm4329_rfkill_probe(struct platform_device *pdev)
+{
+       int rc = 0;
+       bool default_state = true;
+
+       DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+
+       /* default to bluetooth off */
+       bcm4329_set_block(NULL, default_state); /* blocked -> bt off */
+
+       gBtCtrl.bt_rfk = rfkill_alloc(bt_name,
+                NULL,
+                RFKILL_TYPE_BLUETOOTH,
+                &bcm4329_rfk_ops,
+                NULL);
+
+       if (!gBtCtrl.bt_rfk)
+       {
+               printk("fail to rfkill_allocate************\n");
+               return -ENOMEM;
+       }
+
+       rfkill_set_states(gBtCtrl.bt_rfk, default_state, false);
+
+       rc = rfkill_register(gBtCtrl.bt_rfk);
+       if (rc)
+       {
+               printk("failed to rfkill_register,rc=0x%x\n",rc);
+               rfkill_destroy(gBtCtrl.bt_rfk);
+       }
+
+       gpio_request(BT_GPIO_POWER, NULL);
+       gpio_request(BT_GPIO_RESET, NULL);
+       gpio_request(BT_GPIO_WAKE_UP, NULL);
+
+#if BT_WAKE_HOST_SUPPORT
+    init_timer(&(gBtCtrl.tl));
+    gBtCtrl.tl.expires = jiffies + BT_WAKE_LOCK_TIMEOUT*HZ;
+    gBtCtrl.tl.function = timer_hostSleep;
+    add_timer(&(gBtCtrl.tl));
+    gBtCtrl.b_HostWake = false;
+
+       wake_lock_init(&(gBtCtrl.bt_wakelock), WAKE_LOCK_SUSPEND, "bt_wake");
+
+       rc = gpio_request(BT_GPIO_WAKE_UP_HOST, "bt_wake");
+       if (rc) {
+               printk("%s:failed to request RAHO_BT_WAKE_UP_HOST\n",__FUNCTION__);
+       }
+
+       IOMUX_BT_GPIO_WAKE_UP_HOST();
+       gpio_pull_updown(BT_GPIO_WAKE_UP_HOST,GPIOPullUp);
+       rc = request_irq(gpio_to_irq(BT_GPIO_WAKE_UP_HOST),bcm4329_wake_host_irq,IRQF_TRIGGER_FALLING,NULL,NULL);
+       if(rc)
+       {
+               printk("%s:failed to request RAHO_BT_WAKE_UP_HOST irq\n",__FUNCTION__);
+               gpio_free(BT_GPIO_WAKE_UP_HOST);
+       }
+       enable_irq_wake(gpio_to_irq(BT_GPIO_WAKE_UP_HOST)); // so RAHO_BT_WAKE_UP_HOST can wake up system
+
+       printk(KERN_INFO "bcm4329 module has been initialized,rc=0x%x\n",rc);
+ #endif
+
+       return rc;
+
+
+}
+
+
+static int __devexit bcm4329_rfkill_remove(struct platform_device *pdev)
+{
+       if (gBtCtrl.bt_rfk)
+               rfkill_unregister(gBtCtrl.bt_rfk);
+       gBtCtrl.bt_rfk = NULL;
+#if BT_WAKE_HOST_SUPPORT
+    del_timer(&(gBtCtrl.tl));//ɾµô¶¨Ê±Æ÷
+    btWakeupHostUnlock();
+    wake_lock_destroy(&(gBtCtrl.bt_wakelock));
+#endif
+       platform_set_drvdata(pdev, NULL);
+
+       DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       return 0;
+}
+
+static struct platform_driver bcm4329_rfkill_driver = {
+       .probe = bcm4329_rfkill_probe,
+       .remove = __devexit_p(bcm4329_rfkill_remove),
+       .driver = {
+               .name = "rk29sdk_rfkill",
+               .owner = THIS_MODULE,
+       },
+#if BT_WAKE_HOST_SUPPORT
+    .suspend = bcm4329_rfkill_suspend,
+    .resume = bcm4329_rfkill_resume,
+#endif
+};
+
+/*
+ * Module initialization
+ */
+static int __init bcm4329_mod_init(void)
+{
+       int ret;
+       DBG("Enter::%s,line=%d\n",__FUNCTION__,__LINE__);
+       ret = platform_driver_register(&bcm4329_rfkill_driver);
+       printk("ret=0x%x\n", ret);
+       return ret;
+}
+
+static void __exit bcm4329_mod_exit(void)
+{
+       platform_driver_unregister(&bcm4329_rfkill_driver);
+}
+
+module_init(bcm4329_mod_init);
+module_exit(bcm4329_mod_exit);
+MODULE_DESCRIPTION("bcm4329 Bluetooth driver");
+MODULE_AUTHOR("roger_chen cz@rock-chips.com");
+MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-rk29/board-rk29-td8801_v2.c b/arch/arm/mach-rk29/board-rk29-td8801_v2.c
new file mode 100755 (executable)
index 0000000..cd62c6c
--- /dev/null
@@ -0,0 +1,3659 @@
+/* arch/arm/mach-rk29/board-rk29-phonesdk.c
+ *
+ * Copyright (C) 2010 ROCKCHIP, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/skbuff.h>
+#include <linux/spi/spi.h>
+#include <linux/mmc/host.h>
+#include <linux/android_pmem.h>
+#include <linux/usb/android_composite.h>
+
+#include <mach/hardware.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/flash.h>
+#include <asm/hardware/gic.h>
+
+#include <mach/iomux.h>
+#include <mach/gpio.h>
+#include <mach/irqs.h>
+#include <mach/rk29_iomap.h>
+#include <mach/board.h>
+#include <mach/rk29_nand.h>
+#include <mach/rk29_camera.h>                          /* ddl@rock-chips.com : camera support */
+#include <media/soc_camera.h>                               /* ddl@rock-chips.com : camera support */
+#include <mach/vpu_mem.h>
+#include <mach/sram.h>
+#include <mach/ddr.h>
+#include <mach/cpufreq.h>
+
+#include <linux/regulator/rk29-pwm-regulator.h>
+#include <linux/regulator/machine.h>
+#include <linux/mfd/wm831x/pdata.h>
+#include <linux/mfd/wm831x/core.h>
+#include <linux/mfd/wm831x/gpio.h>
+
+#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
+#include <linux/i2c-gpio.h>
+#include <linux/mpu.h>
+#include "devices.h"
+
+
+#if defined(CONFIG_TDSC8800)
+#include <linux/mtk23d.h>
+#endif
+
+#ifdef CONFIG_USE_GPIO_GENERATE_WAVE
+#include "../../../drivers/testcode/gpio_wave.h"
+#endif
+
+#include "../../../drivers/headset_observe/rk_headset.h"
+#include "../../../drivers/staging/android/timed_gpio.h"
+/*set touchscreen different type header*/
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI)
+#include "../../../drivers/input/touchscreen/xpt2046_ts.h"
+#elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
+#include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h"
+#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
+#include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h"
+#endif
+#include "../../../drivers/misc/gps/rk29_gps.h"
+#include "../../../drivers/tty/serial/sc8800.h"
+#ifdef CONFIG_VIDEO_RK29
+/*---------------- Camera Sensor Macro Define Begin  ------------------------*/
+/*---------------- Camera Sensor Configuration Macro Begin ------------------------*/
+#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5640                      /* back camera sensor */
+#define CONFIG_SENSOR_IIC_ADDR_0           0x78
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_0    3
+#define CONFIG_SENSOR_POWER_PIN_0         INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_0         INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_0       RK29_PIN6_PB7
+#define CONFIG_SENSOR_FALSH_PIN_0         RK29_PIN6_PB5
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_H
+
+#define CONFIG_SENSOR_TORCH_PIN_0         RK29_PIN4_PD1
+
+
+#define CONFIG_SENSOR_1 RK29_CAM_SENSOR_GC0309                      /* front camera sensor */
+#define CONFIG_SENSOR_IIC_ADDR_1           0x42
+#define CONFIG_SENSOR_IIC_ADAPTER_ID_1    3
+#define CONFIG_SENSOR_POWER_PIN_1         INVALID_GPIO
+#define CONFIG_SENSOR_RESET_PIN_1         INVALID_GPIO
+#define CONFIG_SENSOR_POWERDN_PIN_1       RK29_PIN5_PD7
+#define CONFIG_SENSOR_FALSH_PIN_1         INVALID_GPIO
+#define CONFIG_SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
+#define CONFIG_SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
+#define CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
+#define CONFIG_SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
+
+#define CONFIG_SENSOR_TORCH_PIN_1         RK29_PIN4_PD1
+
+#endif  //#ifdef CONFIG_VIDEO_RK29
+/*---------------- Camera Sensor Configuration Macro End------------------------*/
+#include "../../../drivers/media/video/rk29_camera.c"
+/*---------------- Camera Sensor Macro Define End  ------------------------*/
+
+
+#include "../../../drivers/cmmb/siano/smsspiphy.h"
+/* Set memory size of pmem */
+#ifdef CONFIG_RK29_MEM_SIZE_M
+#define SDRAM_SIZE          (CONFIG_RK29_MEM_SIZE_M * SZ_1M)
+#else
+#define SDRAM_SIZE          SZ_512M
+#endif
+#define PMEM_GPU_SIZE       SZ_64M
+#define PMEM_UI_SIZE        SZ_32M
+#define PMEM_VPU_SIZE       SZ_64M
+#define PMEM_CAM_SIZE       PMEM_CAM_NECESSARY
+#ifdef CONFIG_VIDEO_RK29_WORK_IPP
+#define MEM_CAMIPP_SIZE     PMEM_CAMIPP_NECESSARY
+#else
+#define MEM_CAMIPP_SIZE     0
+#endif
+#define MEM_FB_SIZE         (3*SZ_2M)//(3*SZ_2M)
+#ifdef CONFIG_FB_WORK_IPP
+#define MEM_FBIPP_SIZE      SZ_2M//SZ_8M   //1920 x 1080 x 2 x 2  //RGB565 = x2;RGB888 = x4
+#else
+#define MEM_FBIPP_SIZE      0
+#endif
+#if SDRAM_SIZE > SZ_512M
+#define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SZ_512M - PMEM_GPU_SIZE)
+#else
+#define PMEM_GPU_BASE       (RK29_SDRAM_PHYS + SDRAM_SIZE - PMEM_GPU_SIZE)
+#endif
+#define PMEM_UI_BASE        (PMEM_GPU_BASE - PMEM_UI_SIZE)
+#define PMEM_VPU_BASE       (PMEM_UI_BASE - PMEM_VPU_SIZE)
+#define PMEM_CAM_BASE       (PMEM_VPU_BASE - PMEM_CAM_SIZE)
+#define MEM_CAMIPP_BASE     (PMEM_CAM_BASE - MEM_CAMIPP_SIZE)
+#define MEM_FB_BASE         (MEM_CAMIPP_BASE - MEM_FB_SIZE)
+#define MEM_FBIPP_BASE      (MEM_FB_BASE - MEM_FBIPP_SIZE)
+#define LINUX_SIZE          (MEM_FBIPP_BASE - RK29_SDRAM_PHYS)
+
+#define PREALLOC_WLAN_SEC_NUM           4
+#define PREALLOC_WLAN_BUF_NUM           160
+#define PREALLOC_WLAN_SECTION_HEADER    24
+
+#define WLAN_SECTION_SIZE_0     (PREALLOC_WLAN_BUF_NUM * 128)
+#define WLAN_SECTION_SIZE_1     (PREALLOC_WLAN_BUF_NUM * 128)
+#define WLAN_SECTION_SIZE_2     (PREALLOC_WLAN_BUF_NUM * 512)
+#define WLAN_SECTION_SIZE_3     (PREALLOC_WLAN_BUF_NUM * 1024)
+
+#define WLAN_SKB_BUF_NUM        16
+#define UNLOCK_SECURITY_KEY     ~(0x1<<5)
+#define LOCK_SECURITY_KEY       0x00
+
+static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
+
+struct wifi_mem_prealloc {
+        void *mem_ptr;
+        unsigned long size;
+};
+
+extern struct sys_timer rk29_timer;
+
+static int rk29_nand_io_init(void)
+{
+    return 0;
+}
+
+struct rk29_nand_platform_data rk29_nand_data = {
+    .width      = 1,     /* data bus width in bytes */
+    .hw_ecc     = 1,     /* hw ecc 0: soft ecc */
+    .num_flash    = 1,
+    .io_init   = rk29_nand_io_init,
+};
+
+#ifdef CONFIG_FB_RK29
+/*****************************************************************************************
+ * lcd  devices
+ * author: zyw@rock-chips.com
+ *****************************************************************************************/
+//#ifdef  CONFIG_LCD_TD043MGEA1
+#define LCD_RXD_PIN          RK29_PIN2_PC7
+#define LCD_TXD_PIN         RK29_PIN3_PA1// RK29_PIN2_PC6
+#define LCD_CLK_PIN          RK29_PIN3_PA2//RK29_PIN2_PC4
+#define LCD_CS_PIN           RK29_PIN3_PA5//RK29_PIN2_PC5
+/*****************************************************************************************
+* frame buffer  devices
+* author: zyw@rock-chips.com
+*****************************************************************************************/
+#define FB_ID                       0
+#define FB_DISPLAY_ON_PIN           INVALID_GPIO//RK29_PIN6_PD0
+#define FB_LCD_STANDBY_PIN          INVALID_GPIO//RK29_PIN6_PD1
+#define FB_LCD_CABC_EN_PIN          INVALID_GPIO//RK29_PIN6_PD2
+#define FB_MCU_FMK_PIN              INVALID_GPIO
+
+#define FB_DISPLAY_ON_VALUE         GPIO_HIGH
+#define FB_LCD_STANDBY_VALUE        GPIO_HIGH
+
+//#endif
+static int rk29_lcd_io_init(void)
+{
+    int ret = 0;
+    //printk("rk29_lcd_io_init\n");
+    //ret = gpio_request(LCD_RXD_PIN, NULL);
+    ret = gpio_request(LCD_TXD_PIN, NULL);
+       ret = gpio_request(LCD_CLK_PIN, NULL);
+       ret = gpio_request(LCD_CS_PIN, NULL);
+       //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_GPIO2C7);
+       rk29_mux_api_set(GPIO3A1_I2S1SCLK_NAME,GPIO3L_GPIO3A1);
+       rk29_mux_api_set(GPIO3A5_I2S1LRCKTX_NAME,GPIO3L_GPIO3A5);
+       rk29_mux_api_set(GPIO3A2_I2S1LRCKRX_NAME,GPIO3L_GPIO3A2);
+    return ret;
+}
+
+static int rk29_lcd_io_deinit(void)
+{
+    int ret = 0;
+    //printk("rk29_lcd_io_deinit\n");
+    gpio_free(LCD_CS_PIN);
+       gpio_free(LCD_CLK_PIN);
+       gpio_free(LCD_TXD_PIN);
+       //gpio_free(LCD_RXD_PIN);
+       //rk29_mux_api_set(GPIO2C7_SPI1RXD_NAME,GPIO2H_SPI1_RXD);
+       //rk29_mux_api_set(GPIO2C6_SPI1TXD_NAME,GPIO2H_SPI1_TXD);
+       ///rk29_mux_api_set(GPIO2C5_SPI1CSN0_NAME,GPIO2H_SPI1_CSN0);
+       //rk29_mux_api_set(GPIO2C4_SPI1CLK_NAME,GPIO2H_SPI1_CLK);
+       rk29_mux_api_set(GPIO3A1_I2S1SCLK_NAME,GPIO3L_I2S1_SCLK);
+       rk29_mux_api_set(GPIO3A5_I2S1LRCKTX_NAME,GPIO3L_I2S1_LRCK_TX);
+       rk29_mux_api_set(GPIO3A2_I2S1LRCKRX_NAME,GPIO3L_I2S1_LRCK_RX);
+    return ret;
+}
+
+static struct rk29lcd_info rk29_lcd_info = {
+    .txd_pin  = LCD_TXD_PIN,
+    .clk_pin = LCD_CLK_PIN,
+    .cs_pin = LCD_CS_PIN,
+    .io_init   = rk29_lcd_io_init,
+    .io_deinit = rk29_lcd_io_deinit,
+};
+
+int rk29_fb_io_enable(void)
+{
+    if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
+        gpio_set_value(FB_DISPLAY_ON_PIN, FB_DISPLAY_ON_VALUE);
+    }
+    if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
+        gpio_set_value(FB_LCD_STANDBY_PIN, FB_LCD_STANDBY_VALUE);
+    }
+    return 0;
+}
+
+int rk29_fb_io_disable(void)
+{
+    if(FB_DISPLAY_ON_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_DISPLAY_ON_PIN, 0);
+        gpio_set_value(FB_DISPLAY_ON_PIN, !FB_DISPLAY_ON_VALUE);
+    }
+    if(FB_LCD_STANDBY_PIN != INVALID_GPIO)
+    {
+        gpio_direction_output(FB_LCD_STANDBY_PIN, 0);
+        gpio_set_value(FB_LCD_STANDBY_PIN, !FB_LCD_STANDBY_VALUE);
+    }
+    return 0;
+}
+
+static int rk29_fb_io_init(struct rk29_fb_setting_info *fb_setting)
+{
+    int ret = 0;
+    if(fb_setting->mcu_fmk_en && (FB_MCU_FMK_PIN != INVALID_GPIO))
+    {
+        ret = gpio_request(FB_MCU_FMK_PIN, NULL);
+        if(ret != 0)
+        {
+            gpio_free(FB_MCU_FMK_PIN);
+            printk(">>>>>> FB_MCU_FMK_PIN gpio_request err \n ");
+        }
+        gpio_direction_input(FB_MCU_FMK_PIN);
+    }
+    if(fb_setting->disp_on_en && (FB_DISPLAY_ON_PIN != INVALID_GPIO))
+    {
+        ret = gpio_request(FB_DISPLAY_ON_PIN, NULL);
+        if(ret != 0)
+        {
+            gpio_free(FB_DISPLAY_ON_PIN);
+            printk(">>>>>> FB_DISPLAY_ON_PIN gpio_request err \n ");
+        }
+    }
+
+    if(fb_setting->disp_on_en && (FB_LCD_STANDBY_PIN != INVALID_GPIO))
+    {
+        ret = gpio_request(FB_LCD_STANDBY_PIN, NULL);
+        if(ret != 0)
+        {
+            gpio_free(FB_LCD_STANDBY_PIN);
+            printk(">>>>>> FB_LCD_STANDBY_PIN gpio_request err \n ");
+        }
+    }
+
+    if(FB_LCD_CABC_EN_PIN != INVALID_GPIO)
+    {
+        ret = gpio_request(FB_LCD_CABC_EN_PIN, NULL);
+        if(ret != 0)
+        {
+            gpio_free(FB_LCD_CABC_EN_PIN);
+            printk(">>>>>> FB_LCD_CABC_EN_PIN gpio_request err \n ");
+        }
+        gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
+        gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
+    }
+    rk29_fb_io_enable();   //enable it
+
+    return ret;
+}
+
+static struct rk29fb_info rk29_fb_info = {
+    .fb_id   = FB_ID,
+    .mcu_fmk_pin = FB_MCU_FMK_PIN,
+    .lcd_info = &rk29_lcd_info,
+    .io_init   = rk29_fb_io_init,
+    .io_enable = rk29_fb_io_enable,
+    .io_disable = rk29_fb_io_disable,
+};
+
+/* rk29 fb resource */
+static struct resource rk29_fb_resource[] = {
+       [0] = {
+        .name  = "lcdc reg",
+               .start = RK29_LCDC_PHYS,
+               .end   = RK29_LCDC_PHYS + RK29_LCDC_SIZE - 1,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+           .name  = "lcdc irq",
+               .start = IRQ_LCDC,
+               .end   = IRQ_LCDC,
+               .flags = IORESOURCE_IRQ,
+       },
+       [2] = {
+           .name   = "win1 buf",
+        .start  = MEM_FB_BASE,
+        .end    = MEM_FB_BASE + MEM_FB_SIZE - 1,
+        .flags  = IORESOURCE_MEM,
+    },
+    #ifdef CONFIG_FB_WORK_IPP
+    [3] = {
+           .name   = "win1 ipp buf",
+        .start  = MEM_FBIPP_BASE,
+        .end    = MEM_FBIPP_BASE + MEM_FBIPP_SIZE - 1,
+        .flags  = IORESOURCE_MEM,
+    },
+    #endif
+};
+
+/*platform_device*/
+struct platform_device rk29_device_fb = {
+       .name             = "rk29-fb",
+       .id               = 4,
+       .num_resources    = ARRAY_SIZE(rk29_fb_resource),
+       .resource         = rk29_fb_resource,
+       .dev            = {
+               .platform_data  = &rk29_fb_info,
+       }
+};
+
+struct platform_device rk29_device_dma_cpy = {
+       .name             = "dma_memcpy",
+       .id               = 4,
+
+};
+
+#endif
+
+static struct android_pmem_platform_data android_pmem_pdata = {
+       .name           = "pmem",
+       .start          = PMEM_UI_BASE,
+       .size           = PMEM_UI_SIZE,
+       .no_allocator   = 0,
+       .cached         = 1,
+};
+
+static struct platform_device android_pmem_device = {
+       .name           = "android_pmem",
+       .id             = 0,
+       .dev            = {
+               .platform_data = &android_pmem_pdata,
+       },
+};
+
+
+static struct vpu_mem_platform_data vpu_mem_pdata = {
+       .name           = "vpu_mem",
+       .start          = PMEM_VPU_BASE,
+       .size           = PMEM_VPU_SIZE,
+       .cached         = 1,
+};
+
+static struct platform_device rk29_vpu_mem_device = {
+       .name           = "vpu_mem",
+       .id                 = 2,
+       .dev            = {
+       .platform_data = &vpu_mem_pdata,
+       },
+};
+
+static struct platform_device rk29_v4l2_output_devce = {
+       .name           = "rk29_vout",
+};
+
+/* HANNSTAR_P1003 touch I2C */
+#if defined (CONFIG_HANNSTAR_P1003)
+#define TOUCH_RESET_PIN RK29_PIN6_PC3
+#define TOUCH_INT_PIN   RK29_PIN4_PD5
+
+int p1003_init_platform_hw(void)
+{
+    if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
+      gpio_free(TOUCH_RESET_PIN);
+      printk("p1003_init_platform_hw gpio_request error\n");
+      return -EIO;
+    }
+
+    if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
+      gpio_free(TOUCH_INT_PIN);
+      printk("p1003_init_platform_hw gpio_request error\n");
+      return -EIO;
+    }
+    gpio_pull_updown(TOUCH_INT_PIN, 1);
+    gpio_direction_output(TOUCH_RESET_PIN, 0);
+    msleep(500);
+    gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
+    msleep(500);
+    gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
+
+    return 0;
+}
+
+
+struct p1003_platform_data p1003_info = {
+  .model= 1003,
+  .init_platform_hw= p1003_init_platform_hw,
+
+};
+#endif
+
+
+#if defined(CONFIG_TOUCHSCREEN_GT801_IIC)
+#include "../../../drivers/input/touchscreen/gt801_ts.h"
+#define GT801_GPIO_INT      RK29_PIN4_PD5
+#define GT801_GPIO_RESET    RK29_PIN6_PC3
+static struct gt801_platform_data gt801_info = {
+       .model                  = 801,
+       .swap_xy                = 0,
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .gpio_reset     = GT801_GPIO_RESET,
+       .gpio_reset_active_low = 0,
+       .gpio_pendown           = GT801_GPIO_INT,
+    .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+    .resetpin_iomux_name = NULL,
+    .pendown_iomux_mode = GPIO4H_GPIO4D5,
+    .resetpin_iomux_mode = 0,
+};
+#endif
+
+
+#if defined(CONFIG_TOUCHSCREEN_GT818_IIC)
+#include "../../../drivers/input/touchscreen/gt818_ts.h"
+#define GT818_GPIO_INT      RK29_PIN4_PD5
+#define GT818_GPIO_RESET    RK29_PIN6_PC3
+static struct gt818_platform_data gt818_info = {
+       .model                  = 818,
+       .swap_xy                = 0,
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .gpio_reset     = GT818_GPIO_RESET,
+       .gpio_reset_active_low = 0,
+       .gpio_pendown           = GT818_GPIO_INT,
+    .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+    .resetpin_iomux_name = NULL,
+    .pendown_iomux_mode = GPIO4H_GPIO4D5,
+    .resetpin_iomux_mode = 0,
+};
+#endif
+
+#if defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
+#include "../../../drivers/input/touchscreen/ili2102_ts.h"
+#define GT801_GPIO_INT      RK29_PIN4_PD5
+#define GT801_GPIO_RESET    RK29_PIN6_PC3
+static struct ili2102_platform_data ili2102_info = {
+       .model                  = 2102,
+       .swap_xy                = 0,
+       .x_min                  = 0,
+       .x_max                  = 481,
+       .y_min                  = 0,
+       .y_max                  = 801,
+       .gpio_reset     = GT801_GPIO_RESET,
+       .gpio_reset_active_low = 1,
+       .gpio_pendown           = GT801_GPIO_INT,
+    .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+    .resetpin_iomux_name = NULL,
+    .pendown_iomux_mode = GPIO4H_GPIO4D5,
+    .resetpin_iomux_mode = 0,
+};
+#endif
+
+/* EETI_EGALAX touch I2C */
+#if defined (CONFIG_EETI_EGALAX)
+#define TOUCH_RESET_PIN RK29_PIN6_PC3
+#define TOUCH_INT_PIN   RK29_PIN4_PD5
+
+static int EETI_EGALAX_init_platform_hw(void)
+{
+    if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
+      gpio_free(TOUCH_RESET_PIN);
+      printk("p1003_init_platform_hw gpio_request error\n");
+      return -EIO;
+    }
+
+    if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
+      gpio_free(TOUCH_INT_PIN);
+      printk("p1003_init_platform_hw gpio_request error\n");
+      return -EIO;
+    }
+    gpio_pull_updown(TOUCH_INT_PIN, 1);
+    gpio_direction_output(TOUCH_RESET_PIN, 0);
+    msleep(500);
+    gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
+    msleep(500);
+    gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
+
+    return 0;
+}
+
+
+static struct eeti_egalax_platform_data eeti_egalax_info = {
+  .model= 1003,
+  .init_platform_hw= EETI_EGALAX_init_platform_hw,
+
+};
+
+#endif
+
+#if defined(CONFIG_TOUCHSCREEN_PIXCIR)
+#include "../../../drivers/input/touchscreen/pixcir_i2c_ts.h"
+static struct pixcir_platform_data pixcir_info = {
+       .model                  = 801,
+       .swap_xy                = 0,
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .gpio_reset     = RK29_PIN6_PC3,
+       .gpio_reset_active_low = 1,
+       .gpio_pendown           = RK29_PIN4_PD5,
+    .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+    .resetpin_iomux_name = NULL,
+    .pendown_iomux_mode = GPIO4H_GPIO4D5,
+    .resetpin_iomux_mode = 0,
+};
+#endif
+
+#if defined(CONFIG_TOUCHSCREEN_FT5X0X)
+#include "../../../drivers/input/touchscreen/ft5x0x_ts.h"
+static struct ft5x0x_platform_data ft5x0x_info = {
+       .model                  = 5000,
+       .swap_xy                = 0,
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .gpio_reset     = RK29_PIN6_PC3,
+       .gpio_reset_active_low = 1,
+       .gpio_pendown           = RK29_PIN4_PD5,
+    .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+    .resetpin_iomux_name = NULL,
+    .pendown_iomux_mode = GPIO4H_GPIO4D5,
+    .resetpin_iomux_mode = 0,
+};
+#endif
+/*MMA8452 gsensor*/
+#if defined (CONFIG_GS_MMA8452)
+#define MMA8452_INT_PIN   RK29_PIN6_PC4
+
+static int mma8452_init_platform_hw(void)
+{
+
+    if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
+      gpio_free(MMA8452_INT_PIN);
+      printk("mma8452_init_platform_hw gpio_request error\n");
+      return -EIO;
+    }
+    gpio_pull_updown(MMA8452_INT_PIN, 1);
+    return 0;
+}
+
+
+static struct mma8452_platform_data mma8452_info = {
+  .model= 8452,
+  .swap_xy = 0,
+  .init_platform_hw= mma8452_init_platform_hw,
+
+};
+#endif
+/*BMA023 gsensor*/
+#if defined (CONFIG_GS_BMA023)
+#define BMA023_INT_PIN   RK29_PIN6_PC4
+
+static int bma023_init_platform_hw(void)
+{
+
+    if(gpio_request(BMA023_INT_PIN,NULL) != 0){
+      gpio_free(BMA023_INT_PIN);
+      printk("bma023_init_platform_hw gpio_request error\n");
+      return -EIO;
+    }
+    gpio_pull_updown(BMA023_INT_PIN, 1);
+    return 0;
+}
+
+
+static struct bma023_platform_data bma023_info = {
+  .model= 023,
+  .swap_xy = 0,
+  .swap_xyz = 1,
+  .orientation = {1,0,0,
+                          0,0,1,
+                          0,1,0},
+  .init_platform_hw= bma023_init_platform_hw,
+
+};
+#endif
+#if defined (CONFIG_MPU_SENSORS_MPU3050)
+/*mpu3050*/
+static struct mpu3050_platform_data mpu3050_data = {
+               .int_config = 0x10,
+               //.orientation = { 1, 0, 0,0, -1, 0,0, 0, 1 },
+               //.orientation = { 0, 1, 0,-1, 0, 0,0, 0, -1 },
+               //.orientation = { -1, 0, 0,0, -1, 0,0, 0, -1 },
+               //.orientation = { 0, 1, 0, -1, 0, 0, 0, 0, 1 },
+               .orientation = { 1, 0, 0,0, 1, 0, 0, 0, 1 },
+               .level_shifter = 0,
+#if defined (CONFIG_MPU_SENSORS_KXTF9)
+               .accel = {
+#ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
+                               .get_slave_descr = NULL ,
+#else
+                               .get_slave_descr = get_accel_slave_descr ,
+#endif
+                               .adapt_num = 0, // The i2c bus to which the mpu device is
+                               // connected
+                               //.irq = RK29_PIN6_PC4,
+                               .bus = EXT_SLAVE_BUS_SECONDARY,  //The secondary I2C of MPU
+                               .address = 0x0f,
+                               //.orientation = { 1, 0, 0,0, 1, 0,0, 0, 1 },
+                               //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
+                               //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
+                               //.orientation = { 0, 1 ,0, -1 ,0, 0, 0, 0, 1 },
+                               .orientation = {1, 0, 0, 0, 1, 0, 0, 0, 1},
+               },
+#endif
+#if defined (CONFIG_MPU_SENSORS_AK8975)
+               .compass = {
+#ifdef CONFIG_MPU_SENSORS_MPU3050_MODULE
+                               .get_slave_descr = NULL,/*ak5883_get_slave_descr,*/
+#else
+                               .get_slave_descr = get_compass_slave_descr,
+#endif
+                               .adapt_num = 0, // The i2c bus to which the compass device is.
+                               // It can be difference with mpu
+                               // connected
+                               //.irq = RK29_PIN6_PC5,
+                               .bus = EXT_SLAVE_BUS_PRIMARY,
+                               .address = 0x0d,
+                               //.orientation = { -1, 0, 0,0, -1, 0,0, 0, 1 },
+                               //.orientation = { 0, -1, 0,-1, 0, 0,0, 0, -1 },
+                               //.orientation = { 0, 1, 0,1, 0, 0,0, 0, -1 },
+                               //.orientation = { 0, -1, 0, 1, 0, 0, 0, 0, 1 },
+                               .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
+               },
+#endif
+};
+#endif
+
+#if defined(CONFIG_GPIO_WM831X)
+struct rk29_gpio_expander_info  wm831x_gpio_settinginfo[] = {
+       {
+               .gpio_num               =WM831X_P01,// tp3
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+
+        {
+               .gpio_num               =WM831X_P02,//tp4
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P03,//tp2
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P04,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P05,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P06,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P07,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P08,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P09,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P10,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P11,//tp1
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+        {
+               .gpio_num               =WM831X_P12,
+               .pin_type           = GPIO_OUT,
+               .pin_value                      =GPIO_HIGH,
+        },
+};
+
+#endif
+
+
+
+#if defined(CONFIG_MFD_WM831X)
+static struct wm831x *gWm831x;
+int wm831x_pre_init(struct wm831x *parm)
+{
+       int ret;
+       printk("%s\n", __FUNCTION__);
+       gWm831x = parm;
+       //ILIM = 900ma
+       ret = wm831x_reg_read(parm, WM831X_POWER_STATE) & 0xffff;
+       wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04);
+
+       //BATT_FET_ENA = 1
+    wm831x_reg_write(parm,WM831X_SECURITY_KEY,0x9716); // unlock security key
+    wm831x_set_bits(parm, WM831X_RESET_CONTROL,0x1000,0x1000);
+    ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff&UNLOCK_SECURITY_KEY;// enternal reset active in sleep
+    printk("%s:WM831X_RESET_CONTROL=0x%x\n",__FUNCTION__,ret);
+    wm831x_reg_write(parm, WM831X_RESET_CONTROL, ret);
+
+
+    wm831x_reg_write(parm,WM831X_SECURITY_KEY,LOCK_SECURITY_KEY); // lock security key
+
+
+#if 0
+       wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0);
+       wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 7), 0);
+       printk("%s:disable ldo4 and ldo8 because they are enabled in uboot\n",__FUNCTION__);
+#endif
+       return 0;
+}
+void cmmb_io_set_for_pm(void);
+int wm831x_post_init(struct wm831x *parm)
+{
+       struct regulator *dcdc;
+       struct regulator *ldo;
+
+       dcdc = regulator_get(NULL, "dcdc3");            // 1th IO
+       regulator_set_voltage(dcdc,3000000,3000000);
+       regulator_set_suspend_voltage(dcdc, 2800000);
+       regulator_enable(dcdc);
+       printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
+       regulator_put(dcdc);
+       udelay(100);
+
+       ldo = regulator_get(NULL, "ldo10");     // 1th modem IO
+       regulator_set_voltage(ldo,2800000,2800000);
+       regulator_set_suspend_voltage(ldo,2800000);
+       regulator_enable(ldo);
+       printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+
+       dcdc = regulator_get(NULL, "dcdc2");    // 2th CORE
+       regulator_set_voltage(dcdc,1300000,1300000);
+       regulator_set_suspend_voltage(dcdc,1000000);
+       regulator_enable(dcdc);
+       printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
+       regulator_put(dcdc);
+       udelay(100);
+
+       dcdc = regulator_get(NULL, "dcdc1");    // 3th ddr
+       regulator_set_voltage(dcdc,1800000,1800000);
+       regulator_set_suspend_voltage(dcdc, 1800000);
+       regulator_enable(dcdc);
+       printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
+       regulator_put(dcdc);
+       udelay(100);
+
+       ldo = regulator_get(NULL, "ldo1");              // 3th nand
+       regulator_set_voltage(ldo,1800000,1800000);
+       regulator_set_suspend_voltage(ldo,1800000);
+       regulator_enable(ldo);
+       printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+
+       ldo = regulator_get(NULL, "ldo4");              // 4th usb
+       regulator_set_voltage(ldo,2500000,2500000);
+       regulator_set_suspend_voltage(ldo,0000000);
+       regulator_enable(ldo);
+       printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+
+       ldo = regulator_get(NULL, "ldo7");              // 5th usb
+       regulator_set_voltage(ldo,3300000,3300000);
+       regulator_set_suspend_voltage(ldo,3300000);
+       regulator_enable(ldo);
+       printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+       udelay(100);
+
+       dcdc = regulator_get(NULL, "dcdc4");    // backlight
+       regulator_set_voltage(dcdc,20000000,20000000);
+       regulator_set_suspend_voltage(dcdc, 20000000);
+       regulator_enable(dcdc);
+       printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc));
+       regulator_put(dcdc);
+       udelay(100);
+#if 1
+
+       ldo = regulator_get(NULL, "ldo2");              //lcd
+       regulator_set_voltage(ldo,2800000,2800000);
+       regulator_set_suspend_voltage(ldo,2800000);
+       regulator_enable(ldo);
+       printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+
+
+       ldo = regulator_get(NULL, "ldo5");              //tf
+       regulator_set_voltage(ldo,3000000,3000000);
+       regulator_set_suspend_voltage(ldo,3000000);
+       regulator_enable(ldo);
+       printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo6");              //camera
+       regulator_set_voltage(ldo,2800000,2800000);
+       regulator_set_suspend_voltage(ldo,2800000);
+       regulator_enable(ldo);
+       printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+
+
+/*
+       ldo = regulator_get(NULL, "ldo3");              //sram
+       regulator_set_voltage(ldo,1800000,1800000);
+       regulator_set_suspend_voltage(ldo,1800000);
+       regulator_enable(ldo);
+       printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);     */
+
+
+
+#endif
+
+       ldo = regulator_get(NULL, "ldo11");
+       //regulator_enable(ldo);
+       printk("%s set ldo11=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+
+#if defined(CONFIG_SMS_SPI_ROCKCHIP)
+       cmmb_io_set_for_pm();
+#endif
+
+       return 0;
+}
+
+extern void wm831x_enter_sleep(void);
+extern void wm831x_exit_sleep(void);
+
+void pmu_wm831x_set_suspend_voltage(void)
+{
+
+}
+EXPORT_SYMBOL_GPL(pmu_wm831x_set_suspend_voltage);
+
+void pmu_wm831x_set_resume_voltage(void)
+{
+
+}
+EXPORT_SYMBOL_GPL(pmu_wm831x_set_resume_voltage);
+
+int wm831x_last_deinit(struct wm831x *parm)
+{
+       struct regulator* ldo;
+
+       printk("%s\n", __FUNCTION__);
+       ldo = regulator_get(NULL, "ldo1");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo2");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo3");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo4");
+       //regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo5");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo6");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo7");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo8");
+       //regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo9");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo10");
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       return 0;
+}
+
+struct wm831x_backlight_pdata wm831x_backlight_platdata = {
+       .isink = 1,     /** ISINK to use, 1 or 2 */
+       .max_uA = 19484,    /** Maximum current to allow */
+};
+
+struct wm831x_backup_pdata wm831x_backup_platdata = {
+       .charger_enable = 1,
+       .no_constant_voltage = 0,  /** Disable constant voltage charging */
+       .vlim = 3100,   /** Voltage limit in milivolts */
+       .ilim = 300,   /** Current limit in microamps */
+};
+
+struct wm831x_battery_pdata wm831x_battery_platdata = {
+       .enable = 1,         /** Enable charging */
+       .fast_enable = 1,    /** Enable fast charging */
+       .off_mask = 1,       /** Mask OFF while charging */
+       .trickle_ilim = 200,   /** Trickle charge current limit, in mA */
+       .vsel = 4200,           /** Target voltage, in mV */
+       .eoc_iterm = 50,      /** End of trickle charge current, in mA */
+       .fast_ilim = 500,      /** Fast charge current limit, in mA */
+       .timeout = 480,        /** Charge cycle timeout, in minutes */
+       .syslo = 3500,    /* syslo threshold, in mV*/
+       .sysok = 3500,    /* sysko threshold, in mV*/
+};
+
+struct wm831x_status_pdata wm831x_status_platdata[WM831X_MAX_STATUS] = {
+       {
+       .default_src = WM831X_STATUS_OTP,
+       .name = "wm831x_status0",
+       .default_trigger = "wm831x_otp",
+       },
+       {
+       .default_src = WM831X_STATUS_POWER,
+       .name = "wm831x_status1",
+       .default_trigger = "wm831x_power",
+       },
+};
+
+
+static struct regulator_consumer_supply dcdc1_consumers[] = {
+       {
+               .supply = "dcdc1",
+       }
+};
+static struct regulator_consumer_supply dcdc2_consumers[] = {
+       {
+               .supply = "dcdc2",
+       },
+       {
+               .supply = "vcore",
+       }
+};
+static struct regulator_consumer_supply dcdc3_consumers[] = {
+       {
+               .supply = "dcdc3",
+       }
+};
+static struct regulator_consumer_supply dcdc4_consumers[] = {
+       {
+               .supply = "dcdc4",
+       }
+};
+static struct regulator_consumer_supply epe1_consumers[] = {
+       {
+               .supply = "epe1",
+       }
+};
+static struct regulator_consumer_supply epe2_consumers[] = {
+       {
+               .supply = "epe2",
+       }
+};
+static struct regulator_consumer_supply ldo1_consumers[] = {
+       {
+               .supply = "ldo1",
+       }
+};
+static struct regulator_consumer_supply ldo2_consumers[] = {
+       {
+               .supply = "ldo2",
+       }
+};
+static struct regulator_consumer_supply ldo3_consumers[] = {
+       {
+               .supply = "ldo3",
+       }
+};
+static struct regulator_consumer_supply ldo4_consumers[] = {
+       {
+               .supply = "ldo4",
+       }
+};
+static struct regulator_consumer_supply ldo5_consumers[] = {
+       {
+               .supply = "ldo5",
+       }
+};
+static struct regulator_consumer_supply ldo6_consumers[] = {
+       {
+               .supply = "ldo6",
+       }
+};
+static struct regulator_consumer_supply ldo7_consumers[] = {
+       {
+               .supply = "ldo7",
+       }
+};
+static struct regulator_consumer_supply ldo8_consumers[] = {
+       {
+               .supply = "ldo8",
+       }
+};
+static struct regulator_consumer_supply ldo9_consumers[] = {
+       {
+               .supply = "ldo9",
+       }
+};
+static struct regulator_consumer_supply ldo10_consumers[] = {
+       {
+               .supply = "ldo10",
+       }
+};
+static struct regulator_consumer_supply ldo11_consumers[] = {
+       {
+               .supply = "ldo11",
+       }
+};
+static struct regulator_consumer_supply isink1_consumers[] = {
+       {
+               .supply = "isink1",
+       }
+};
+static struct regulator_consumer_supply isink2_consumers[] = {
+       {
+               .supply = "isink2",
+       }
+};
+
+struct regulator_init_data wm831x_regulator_init_dcdc[WM831X_MAX_DCDC] = {
+       {
+               .constraints = {
+                       .name = "DCDC1",
+                       .min_uV = 600000,
+                       .max_uV = 1800000,//0.6-1.8V
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(dcdc1_consumers),
+               .consumer_supplies = dcdc1_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "DCDC2",
+                       .min_uV = 600000,
+                       .max_uV = 1800000,//0.6-1.8V
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(dcdc2_consumers),
+               .consumer_supplies = dcdc2_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "DCDC3",
+                       .min_uV = 850000,
+                       .max_uV = 3400000,//0.85-3.4V
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(dcdc3_consumers),
+               .consumer_supplies = dcdc3_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "DCDC4",
+                       .min_uV = 00000000,
+                       .max_uV = 30000000,//30V/40mA
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(dcdc4_consumers),
+               .consumer_supplies = dcdc4_consumers,
+       },
+
+};
+struct regulator_init_data wm831x_regulator_init_epe[WM831X_MAX_EPE] = {
+       {
+               .constraints = {
+                       .name = "EPE1",
+                       .min_uV = 1200000,
+                       .max_uV = 3000000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(epe1_consumers),
+               .consumer_supplies = epe1_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "EPE2",
+                       .min_uV = 1200000,
+                       .max_uV = 3000000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(epe2_consumers),
+               .consumer_supplies = epe2_consumers,
+       },
+};
+
+struct regulator_init_data wm831x_regulator_init_ldo[WM831X_MAX_LDO] = {
+       {
+               .constraints = {
+                       .name = "LDO1",
+                       .min_uV = 900000,
+                       .max_uV = 3300000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo1_consumers),
+               .consumer_supplies = ldo1_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO2",
+                       .min_uV = 900000,
+                       .max_uV = 3300000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo2_consumers),
+               .consumer_supplies = ldo2_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO3",
+                       .min_uV = 900000,
+                       .max_uV = 3300000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
+               .consumer_supplies = ldo3_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO4",
+                       .min_uV = 900000,
+                       .max_uV = 3300000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo4_consumers),
+               .consumer_supplies = ldo4_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO5",
+                       .min_uV = 900000,
+                       .max_uV = 3300000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
+               .consumer_supplies = ldo5_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO6",
+                       .min_uV = 900000,
+                       .max_uV = 3300000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo6_consumers),
+               .consumer_supplies = ldo6_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO7",
+                       .min_uV = 1000000,
+                       .max_uV = 3500000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo7_consumers),
+               .consumer_supplies = ldo7_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO8",
+                       .min_uV = 1000000,
+                       .max_uV = 3500000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo8_consumers),
+               .consumer_supplies = ldo8_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO9",
+                       .min_uV = 1000000,
+                       .max_uV = 3500000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo9_consumers),
+               .consumer_supplies = ldo9_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO10",
+                       .min_uV = 1000000,
+                       .max_uV = 3500000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo10_consumers),
+               .consumer_supplies = ldo10_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "LDO11",
+                       .min_uV = 1200000,
+                       .max_uV = 3000000,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(ldo11_consumers),
+               .consumer_supplies = ldo11_consumers,
+       },
+};
+
+struct regulator_init_data wm831x_regulator_init_isink[WM831X_MAX_ISINK] = {
+       {
+               .constraints = {
+                       .name = "ISINK1",
+                       .min_uA = 00000,
+                       .max_uA = 40000,
+                       .always_on = true,
+                       .apply_uV = true,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(isink1_consumers),
+               .consumer_supplies = isink1_consumers,
+       },
+       {
+               .constraints = {
+                       .name = "ISINK2",
+                       .min_uA = 0000000,
+                       .max_uA = 0000000,
+                       .apply_uV = false,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_CURRENT,
+               },
+               .num_consumer_supplies = ARRAY_SIZE(isink2_consumers),
+               .consumer_supplies = isink2_consumers,
+       },
+};
+
+static int wm831x_checkrange(int start,int num,int val)
+{
+       if((val<(start+num))&&(val>=start))
+               return 0;
+       else
+               return -1;
+}
+
+static int wm831x_init_pin_type(struct wm831x *wm831x)
+{
+#if 1
+       struct wm831x_pdata *pdata = wm831x->dev->platform_data;
+       struct rk29_gpio_expander_info *wm831x_gpio_settinginfo;
+       uint16_t offset = 0;
+       uint16_t wm831x_settingpin_num = 0;
+       uint16_t ret = 0;
+       int i = 0;
+
+       if(wm831x)
+       {
+               wm831x_gpio_settinginfo=pdata->settinginfo;
+               if(wm831x_gpio_settinginfo)
+               {
+                       wm831x_settingpin_num = pdata->settinginfolen;
+                       for(i=0;i<wm831x_settingpin_num;i++)
+                       {
+                               if(!wm831x_checkrange(pdata->gpio_base,pdata->gpio_pin_num,wm831x_gpio_settinginfo[i].gpio_num))
+                               {
+                                       offset = wm831x_gpio_settinginfo[i].gpio_num - pdata->gpio_base;
+
+                                       if(wm831x_gpio_settinginfo[i].pin_type==GPIO_IN)
+                                       {
+                                               wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_DIR_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
+                                       }
+                                       else
+                                       {
+                                               wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+offset), WM831X_GPN_DIR_MASK|WM831X_GPN_TRI_MASK, 1<<WM831X_GPN_TRI_SHIFT);
+                                               if(wm831x_gpio_settinginfo[i].pin_value==GPIO_HIGH)
+                                               {
+                                                       wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(1 << offset));
+                                               }
+                                               else
+                                               {
+                                                       wm831x_set_bits(wm831x, WM831X_GPIO_LEVEL, (1 << offset),(0 << offset));
+                                               }
+                                       }
+
+                               }
+                       }
+               }
+       }
+
+       for(i=0;i<pdata->gpio_pin_num;i++)
+       {
+               wm831x_set_bits(wm831x,(WM831X_GPIO1_CONTROL+i),
+                       WM831X_GPN_PULL_MASK|WM831X_GPN_POL_MASK|WM831X_GPN_OD_MASK|WM831X_GPN_TRI_MASK,
+                       1<<WM831X_GPN_POL_SHIFT|1<<WM831X_GPN_TRI_SHIFT);
+               ret =  wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL+i);
+               printk("Gpio%d Pin Configuration = %x\n",i,ret);
+       }
+#endif
+       return 0;
+}
+
+/*
+ * GPIO Buttons
+ */
+#if defined(CONFIG_KEYBOARD_WM831X_GPIO)
+static struct wm831x_gpio_keys_button wm831x_gpio_buttons[] = {
+{
+       .code           = KEY_MEDIA,
+       .gpio           = TCA6424_P21,
+       .active_low     = 1,
+       .desc           = "media",
+       .wakeup         = 0,
+       .debounce_interval = 120,
+},
+{
+    .code= KEY_VOLUMEUP,
+               .gpio= WM831X_P05,
+               .active_low= 1,
+               .desc= "volume_up",
+               .wakeup= 0,
+},
+{
+               .code= KEY_CAMERA,
+               .gpio= WM831X_P06,
+               .active_low= 1,
+               .desc= "camera",
+               .wakeup= 0,
+},
+{
+               .code= KEY_VOLUMEDOWN,
+               .gpio= WM831X_P07,
+               .active_low= 1,
+               .desc= "volume_down",
+               .wakeup= 0,
+},
+{
+               .code= KEY_END,
+               .gpio= WM831X_P09,
+               .active_low= 1,
+               .desc= "enter",
+               .wakeup= 0,
+},
+{
+               .code= KEY_MENU,
+               .gpio= WM831X_P10,
+               .active_low= 1,
+               .desc= "menu",
+               .wakeup= 0,
+},
+{
+               .code= KEY_SEND,
+               .gpio= WM831X_P11,
+               .active_low= 1,
+               .desc= "esc",
+               .wakeup= 0,
+},
+{
+               .code= KEY_BACK,
+               .gpio= WM831X_P12,
+               .active_low= 1,
+               .desc= "home",
+               .wakeup= 0,
+},
+};
+
+struct wm831x_gpio_keys_pdata wm831x_gpio_keys_platdata = {
+       .buttons        = wm831x_gpio_buttons,
+       .nbuttons       = ARRAY_SIZE(wm831x_gpio_buttons),
+};
+
+#endif
+struct wm831x_pdata wm831x_platdata = {
+       /** Called before subdevices are set up */
+       .pre_init= wm831x_pre_init,
+       /** Called after subdevices are set up */
+       .post_init = wm831x_post_init,
+       /** Called before subdevices are power down */
+       .last_deinit = wm831x_last_deinit,
+
+#if defined(CONFIG_GPIO_WM831X)
+       .gpio_base=WM831X_GPIO_EXPANDER_BASE,
+       .gpio_pin_num=WM831X_TOTOL_GPIO_NUM,
+       .settinginfo=wm831x_gpio_settinginfo,
+       .settinginfolen=ARRAY_SIZE(wm831x_gpio_settinginfo),
+       .pin_type_init = wm831x_init_pin_type,
+       .irq_base= NR_AIC_IRQS + 7*NUM_GROUP,
+#endif
+
+       .backlight = &wm831x_backlight_platdata,
+
+       .backup = &wm831x_backup_platdata,
+
+       .battery = &wm831x_battery_platdata,
+       //.wm831x_touch_pdata = NULL,
+       //.watchdog = NULL,
+
+#if defined(CONFIG_KEYBOARD_WM831X_GPIO)
+       .gpio_keys = &wm831x_gpio_keys_platdata,
+#endif
+
+       /** LED1 = 0 and so on */
+       .status = {&wm831x_status_platdata[0], &wm831x_status_platdata[1]},
+
+       /** DCDC1 = 0 and so on */
+       .dcdc = {&wm831x_regulator_init_dcdc[0], &wm831x_regulator_init_dcdc[1], &wm831x_regulator_init_dcdc[2], &wm831x_regulator_init_dcdc[3]},
+
+       /** EPE1 = 0 and so on */
+       .epe = {&wm831x_regulator_init_epe[0], &wm831x_regulator_init_epe[1]},
+
+       /** LDO1 = 0 and so on */
+       .ldo = {&wm831x_regulator_init_ldo[0], &wm831x_regulator_init_ldo[1], &wm831x_regulator_init_ldo[2], &wm831x_regulator_init_ldo[3],
+                       &wm831x_regulator_init_ldo[4], &wm831x_regulator_init_ldo[5], &wm831x_regulator_init_ldo[6], &wm831x_regulator_init_ldo[7],
+                       &wm831x_regulator_init_ldo[8], &wm831x_regulator_init_ldo[9], &wm831x_regulator_init_ldo[10]},
+
+       /** ISINK1 = 0 and so on*/
+       .isink = {&wm831x_regulator_init_isink[0], &wm831x_regulator_init_isink[1]},
+};
+#endif
+
+
+
+#if defined(CONFIG_RK29_GPS)
+
+#define        RK29_GPS_POWER_PIN              RK29_PIN6_PB2
+#define        RK29_GPS_RESET_PIN              RK29_PIN6_PC1
+
+int rk29_gps_power_up(void)
+{
+       printk("%s \n", __FUNCTION__);
+
+    gpio_request(RK29_GPS_POWER_PIN, NULL);
+       gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH);
+
+       return 0;
+}
+
+int rk29_gps_power_down(void)
+{
+       printk("%s \n", __FUNCTION__);
+
+    gpio_request(RK29_GPS_POWER_PIN, NULL);
+       gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW);
+
+       return 0;
+}
+
+int rk29_gps_reset_set(int level)
+{
+       gpio_request(RK29_GPS_RESET_PIN, NULL);
+       if (level)
+               gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH);
+       else
+               gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW);
+
+       return 0;
+}
+
+struct rk29_gps_data rk29_gps_info = {
+       .power_up = rk29_gps_power_up,
+       .power_down = rk29_gps_power_down,
+       .reset = rk29_gps_reset_set,
+       .uart_id = 3,
+};
+
+struct platform_device rk29_device_gps = {
+       .name = "rk29_gps",
+       .id = -1,
+       .dev            = {
+       .platform_data = &rk29_gps_info,
+               }
+       };
+#endif
+
+#ifdef CONFIG_RK_HEADSET_DET
+#define HEADSET_GPIO RK29_PIN4_PD2
+struct rk_headset_pdata rk_headset_info = {
+       .Headset_gpio           = RK29_PIN4_PD2,
+       .headset_in_type= HEADSET_IN_HIGH,
+       .Hook_gpio = RK29_PIN6_PB6,//Detection Headset--Must be set
+       .hook_key_code = KEY_MEDIA,
+};
+
+struct platform_device rk_device_headset = {
+               .name   = "rk_headsetdet",
+               .id     = 0,
+               .dev    = {
+                   .platform_data = &rk_headset_info,
+               }
+};
+#endif
+
+#if defined(CONFIG_GS_L3G4200D)
+
+#include <linux/l3g4200d.h>
+#define L3G4200D_INT_PIN  RK29_PIN5_PA3
+
+static int l3g4200d_init_platform_hw(void)
+{
+       if (gpio_request(L3G4200D_INT_PIN, NULL) != 0) {
+               gpio_free(L3G4200D_INT_PIN);
+               printk("%s: request l3g4200d int pin error\n", __func__);
+               return -EIO;
+       }
+       gpio_pull_updown(L3G4200D_INT_PIN, 1);
+       return 0;
+}
+
+static struct l3g4200d_platform_data l3g4200d_info = {
+       .fs_range = 1,
+
+       .axis_map_x = 0,
+       .axis_map_y = 1,
+       .axis_map_z = 2,
+
+       .negate_x = 1,
+       .negate_y = 1,
+       .negate_z = 0,
+
+       .init = l3g4200d_init_platform_hw,
+};
+
+#endif
+
+/*****************************************************************************************
+ * i2c devices
+ * author: kfx@rock-chips.com
+*****************************************************************************************/
+static int rk29_i2c0_io_init(void)
+{
+#ifdef CONFIG_RK29_I2C0_CONTROLLER
+       rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_I2C0_SCL);
+       rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_I2C0_SDA);
+#else
+       rk29_mux_api_set(GPIO2B7_I2C0SCL_NAME, GPIO2L_GPIO2B7);
+       rk29_mux_api_set(GPIO2B6_I2C0SDA_NAME, GPIO2L_GPIO2B6);
+#endif
+       return 0;
+}
+
+static int rk29_i2c1_io_init(void)
+{
+#ifdef CONFIG_RK29_I2C1_CONTROLLER
+       rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_I2C1_SCL);
+       rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_I2C1_SDA);
+#else
+       rk29_mux_api_set(GPIO1A7_I2C1SCL_NAME, GPIO1L_GPIO1A7);
+       rk29_mux_api_set(GPIO1A6_I2C1SDA_NAME, GPIO1L_GPIO1A6);
+#endif
+       return 0;
+}
+static int rk29_i2c2_io_init(void)
+{
+#ifdef CONFIG_RK29_I2C2_CONTROLLER
+       rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_I2C2_SCL);
+       rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_I2C2_SDA);
+#else
+       rk29_mux_api_set(GPIO5D4_I2C2SCL_NAME, GPIO5H_GPIO5D4);
+       rk29_mux_api_set(GPIO5D3_I2C2SDA_NAME, GPIO5H_GPIO5D3);
+#endif
+       return 0;
+}
+
+static int rk29_i2c3_io_init(void)
+{
+#ifdef CONFIG_RK29_I2C3_CONTROLLER
+       rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_I2C3_SCL);
+       rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_I2C3_SDA);
+#else
+       rk29_mux_api_set(GPIO2B5_UART3RTSN_I2C3SCL_NAME, GPIO2L_GPIO2B5);
+       rk29_mux_api_set(GPIO2B4_UART3CTSN_I2C3SDA_NAME, GPIO2L_GPIO2B4);
+#endif
+       return 0;
+}
+#ifdef CONFIG_RK29_I2C0_CONTROLLER
+struct rk29_i2c_platform_data default_i2c0_data = {
+       .bus_num    = 0,
+       .flags      = 0,
+       .slave_addr = 0xff,
+       .scl_rate  = 400*1000,
+       .mode           = I2C_MODE_IRQ,
+       .io_init = rk29_i2c0_io_init,
+};
+#else
+struct i2c_gpio_platform_data default_i2c0_data = {
+       .sda_pin = RK29_PIN2_PB6,
+       .scl_pin = RK29_PIN2_PB7,
+       .udelay = 5, // clk = 500/udelay = 100Khz
+       .timeout = 100,//msecs_to_jiffies(200),
+       .bus_num    = 0,
+       .io_init = rk29_i2c0_io_init,
+};
+#endif
+#ifdef CONFIG_RK29_I2C1_CONTROLLER
+struct rk29_i2c_platform_data default_i2c1_data = {
+       .bus_num    = 1,
+       .flags      = 0,
+       .slave_addr = 0xff,
+       .scl_rate  = 400*1000,
+       .mode           = I2C_MODE_IRQ,
+       .io_init = rk29_i2c1_io_init,
+};
+#else
+struct i2c_gpio_platform_data default_i2c1_data = {
+       .sda_pin = RK29_PIN1_PA6,
+       .scl_pin = RK29_PIN1_PA7,
+       .udelay = 5, // clk = 500/udelay = 100Khz
+       .timeout = 100,//msecs_to_jiffies(200),
+       .bus_num    = 1,
+       .io_init = rk29_i2c1_io_init,
+};
+#endif
+#ifdef CONFIG_RK29_I2C2_CONTROLLER
+struct rk29_i2c_platform_data default_i2c2_data = {
+       .bus_num    = 2,
+       .flags      = 0,
+       .slave_addr = 0xff,
+       .scl_rate  = 400*1000,
+       .mode           = I2C_MODE_IRQ,
+       .io_init = rk29_i2c2_io_init,
+};
+#else
+struct i2c_gpio_platform_data default_i2c2_data = {
+       .sda_pin = RK29_PIN5_PD3,
+       .scl_pin = RK29_PIN5_PD4,
+       .udelay = 5, // clk = 500/udelay = 100Khz
+       .timeout = 100,//msecs_to_jiffies(200),
+       .bus_num    = 2,
+       .io_init = rk29_i2c2_io_init,
+};
+#endif
+#ifdef CONFIG_RK29_I2C3_CONTROLLER
+struct rk29_i2c_platform_data default_i2c3_data = {
+       .bus_num    = 3,
+       .flags      = 0,
+       .slave_addr = 0xff,
+       .scl_rate  = 400*1000,
+       .mode           = I2C_MODE_IRQ,
+       .io_init = rk29_i2c3_io_init,
+};
+#else
+struct i2c_gpio_platform_data default_i2c3_data = {
+       .sda_pin = RK29_PIN5_PB5,
+       .scl_pin = RK29_PIN5_PB4,
+       .udelay = 5, // clk = 500/udelay = 100Khz
+       .timeout = 100,//msecs_to_jiffies(200),
+       .bus_num    = 3,
+       .io_init = rk29_i2c3_io_init,
+};
+#endif
+#ifdef CONFIG_I2C0_RK29
+static struct i2c_board_info __initdata board_i2c0_devices[] = {
+#if defined (CONFIG_RK1000_CONTROL)
+       {
+               .type                   = "rk1000_control",
+               .addr           = 0x40,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_SND_SOC_RK1000)
+       {
+               .type                   = "rk1000_i2c_codec",
+               .addr           = 0x60,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_SND_SOC_WM8900)
+       {
+               .type                   = "wm8900",
+               .addr           = 0x1A,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_SND_SOC_WM8994)
+       {
+               .type                   = "wm8994",
+               .addr           = 0x1a,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_BATTERY_STC3100)
+       {
+               .type                   = "stc3100",
+               .addr           = 0x70,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_BATTERY_BQ27510)
+       {
+               .type                   = "bq27510",
+               .addr           = 0x55,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_RTC_HYM8563)
+       {
+               .type                   = "rtc_hym8563",
+               .addr           = 0x51,
+               .flags                  = 0,
+               .irq            = RK29_PIN0_PA1,
+       },
+#endif
+#if defined (CONFIG_GS_MMA8452)
+    {
+      .type           = "gs_mma8452",
+      .addr           = 0x1c,
+      .flags          = 0,
+      .irq            = MMA8452_INT_PIN,
+      .platform_data  = &mma8452_info,
+    },
+#endif
+#if defined (CONFIG_GS_BMA023)
+    {
+      .type           = "bma150",
+      .addr           = 0x38,
+      .flags          = 0,
+      .irq            = BMA023_INT_PIN,
+      .platform_data  = &bma023_info,
+    },
+#endif
+#if defined (CONFIG_COMPASS_AK8973)
+       {
+               .type                   = "ak8973",
+               .addr           = 0x1d,
+               .flags                  = 0,
+               .irq                    = RK29_PIN6_PC5,
+       },
+#endif
+#if defined (CONFIG_COMPASS_AK8975)
+       {
+               .type                   = "ak8975",
+               .addr           = 0x0d,
+               .flags                  = 0,
+               .irq                    = RK29_PIN6_PC5,
+       },
+#endif
+#if defined (CONFIG_INPUT_LPSENSOR_ISL29028)
+       {
+               .type           = "isl29028",
+               .addr           = 0x44,
+               .flags          = 0,
+               .irq            = RK29_PIN4_PD3,
+       },
+#endif
+#if defined (CONFIG_INPUT_LPSENSOR_AL3006)
+       {
+               .type           = "al3006",
+               .addr           = 0x1C,             //sel = 0; if sel =1, then addr = 0x1D
+               .flags          = 0,
+               .irq            = RK29_PIN4_PD3,
+       },
+#endif
+#if defined (CONFIG_ANX7150)
+    {
+               .type           = "anx7150",
+        .addr           = 0x39,             //0x39, 0x3d
+        .flags          = 0,
+        .irq            = RK29_PIN2_PA3,
+    },
+#endif
+#if defined (CONFIG_GS_L3G4200D)
+       {
+               .type           = "gs_l3g4200d",
+               .addr           = 0x69,
+               .flags          = 0,
+               .irq            = L3G4200D_INT_PIN,
+               .platform_data  = &l3g4200d_info,
+       },
+#endif
+#if defined (CONFIG_MPU_SENSORS_MPU3050)
+       {
+               .type                   = "mpu3050",
+               .addr                   = 0x68,
+               .flags                  = 0,
+               .irq                    = RK29_PIN4_PC4,
+               .platform_data  = &mpu3050_data,
+       },
+#endif
+};
+#endif
+
+#ifdef CONFIG_I2C1_RK29
+static struct i2c_board_info __initdata board_i2c1_devices[] = {
+#if defined (CONFIG_RK1000_CONTROL1)
+       {
+               .type                   = "rk1000_control",
+               .addr                   = 0x40,
+               .flags                  = 0,
+       },
+#endif
+#if defined (CONFIG_MFD_WM831X_I2C)
+       {
+               .type                   = "wm8310",
+               .addr                   = 0x34,
+               .flags                  = 0,
+               .irq                    = RK29_PIN4_PD0,
+               .platform_data = &wm831x_platdata,
+       },
+#endif
+
+};
+#endif
+
+#ifdef CONFIG_I2C2_RK29
+static struct i2c_board_info __initdata board_i2c2_devices[] = {
+#if defined (CONFIG_TOUCHSCREEN_GT801_IIC)
+{
+       .type           = "gt801_ts",
+       .addr           = 0x55,
+       .flags          = 0,
+       .irq            = RK29_PIN4_PD5,
+       .platform_data = &gt801_info,
+},
+#endif
+
+#if defined (CONFIG_TOUCHSCREEN_GT818_IIC)
+{
+       .type           = "gt818_ts",
+       .addr           = 0x5d,
+       .flags          = 0,
+       .irq            = RK29_PIN4_PD5,
+       .platform_data = &gt818_info,
+},
+#endif
+
+#if defined (CONFIG_TOUCHSCREEN_ILI2102_IIC)
+{
+       .type           = "ili2102_ts",
+       .addr           = 0x41,
+       .flags          = I2C_M_NEED_DELAY,
+       .udelay      = 600,
+       .irq            = RK29_PIN4_PD5,
+       .platform_data = &ili2102_info,
+},
+#endif
+#if defined (CONFIG_HANNSTAR_P1003)
+    {
+      .type           = "p1003_touch",
+      .addr           = 0x04,
+      .flags          = 0,
+      .irq            = RK29_PIN0_PA2,
+      .platform_data  = &p1003_info,
+    },
+#endif
+#if defined (CONFIG_EETI_EGALAX)
+    {
+      .type           = "egalax_i2c",
+      .addr           = 0x04,
+      .flags          = 0,
+      .irq            = RK29_PIN4_PD5,
+      .platform_data  = &eeti_egalax_info,
+    },
+#endif
+#if defined (CONFIG_TOUCHSCREEN_PIXCIR)
+    {
+      .type           = "pixcir_ts",
+      .addr           = 0x5c,
+      .flags          = 0,
+      .irq            = RK29_PIN4_PD5,
+      .platform_data  = &pixcir_info,
+    },
+#endif
+#if defined (CONFIG_TOUCHSCREEN_FT5X0X)
+    {
+      .type           = "ft5x0x_ts",
+      .addr           = (0x70>>1),
+      .flags          = 0,
+      .irq            = RK29_PIN4_PD5,
+      .platform_data  = &ft5x0x_info,
+    },
+#endif
+};
+#endif
+
+#ifdef CONFIG_I2C3_RK29
+static struct i2c_board_info __initdata board_i2c3_devices[] = {
+       //I2c3 only for  camera
+};
+#endif
+
+/*****************************************************************************************
+ * camera  devices
+ * author: ddl@rock-chips.com
+ *****************************************************************************************/
+#ifdef CONFIG_VIDEO_RK29
+#define CONFIG_SENSOR_POWER_IOCTL_USR      0
+#define CONFIG_SENSOR_RESET_IOCTL_USR      0
+#define CONFIG_SENSOR_POWERDOWN_IOCTL_USR      0
+#define CONFIG_SENSOR_FLASH_IOCTL_USR      1
+
+#if CONFIG_SENSOR_POWER_IOCTL_USR
+static int sensor_power_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+    #error "CONFIG_SENSOR_POWER_IOCTL_USR is 1, sensor_power_usr_cb function must be writed!!";
+}
+#endif
+
+#if CONFIG_SENSOR_RESET_IOCTL_USR
+static int sensor_reset_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+    #error "CONFIG_SENSOR_RESET_IOCTL_USR is 1, sensor_reset_usr_cb function must be writed!!";
+}
+#endif
+
+#if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
+static int sensor_powerdown_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+    #error "CONFIG_SENSOR_POWERDOWN_IOCTL_USR is 1, sensor_powerdown_usr_cb function must be writed!!";
+}
+#endif
+
+#if CONFIG_SENSOR_FLASH_IOCTL_USR
+static int sensor_flash_usr_cb (struct rk29camera_gpio_res *res,int on)
+{
+    //#error "CONFIG_SENSOR_FLASH_IOCTL_USR is 1, sensor_flash_usr_cb function must be writed!!";
+       int ret;
+       ret = gpio_request(RK29_PIN0_PD1, NULL);
+       if(ret != 0)
+       {
+               gpio_free(RK29_PIN0_PD1);
+               printk("sensor_flash_usr_cb error!!\n");
+               return 0;
+       }
+       ret = gpio_request(RK29_PIN6_PB5, NULL);
+       if(ret != 0)
+       {
+               gpio_free(RK29_PIN6_PB5);
+               printk("sensor_flash_usr_cb error!!\n");
+               return 0;
+       }
+       if(on) {
+               gpio_direction_output(RK29_PIN0_PD1, GPIO_HIGH);
+               gpio_set_value(RK29_PIN0_PD1, 1);
+
+               gpio_direction_output(RK29_PIN6_PB5, GPIO_HIGH);
+               gpio_set_value(RK29_PIN6_PB5, 1);
+       }
+       else
+       {
+               gpio_direction_output(RK29_PIN0_PD1, GPIO_HIGH);
+               gpio_set_value(RK29_PIN0_PD1, 0);
+
+               gpio_direction_output(RK29_PIN6_PB5, GPIO_HIGH);
+               gpio_set_value(RK29_PIN6_PB5, 0);
+       }
+       gpio_free(RK29_PIN0_PD1);
+       gpio_free(RK29_PIN6_PB5);
+       return 0;
+}
+#endif
+
+static struct rk29camera_platform_ioctl_cb  sensor_ioctl_cb = {
+    #if CONFIG_SENSOR_POWER_IOCTL_USR
+    .sensor_power_cb = sensor_power_usr_cb,
+    #else
+    .sensor_power_cb = NULL,
+    #endif
+
+    #if CONFIG_SENSOR_RESET_IOCTL_USR
+    .sensor_reset_cb = sensor_reset_usr_cb,
+    #else
+    .sensor_reset_cb = NULL,
+    #endif
+
+    #if CONFIG_SENSOR_POWERDOWN_IOCTL_USR
+    .sensor_powerdown_cb = sensor_powerdown_usr_cb,
+    #else
+    .sensor_powerdown_cb = NULL,
+    #endif
+
+    #if CONFIG_SENSOR_FLASH_IOCTL_USR
+    .sensor_flash_cb = sensor_flash_usr_cb,
+    #else
+    .sensor_flash_cb = NULL,
+    #endif
+};
+#include "../../../drivers/media/video/rk29_camera.c"
+#endif
+
+/*****************************************************************************************
+ * backlight  devices
+ * author: nzy@rock-chips.com
+ *****************************************************************************************/
+#ifdef CONFIG_BACKLIGHT_RK29_BL
+ /*
+ GPIO1B5_PWM0_NAME,       GPIO1L_PWM0
+ GPIO5D2_PWM1_UART1SIRIN_NAME,  GPIO5H_PWM1
+ GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME,   GPIO2L_PWM2
+ GPIO1A5_EMMCPWREN_PWM3_NAME,     GPIO1L_PWM3
+ */
+
+#define PWM_ID            0
+#define PWM_MUX_NAME      GPIO1B5_PWM0_NAME
+#define PWM_MUX_MODE      GPIO1L_PWM0
+#define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
+#define PWM_EFFECT_VALUE  1
+
+//#define LCD_DISP_ON_PIN
+
+#ifdef  LCD_DISP_ON_PIN
+#define BL_EN_MUX_NAME    GPIOF34_UART3_SEL_NAME
+#define BL_EN_MUX_MODE    IOMUXB_GPIO1_B34
+
+#define BL_EN_PIN         GPIO0L_GPIO0A5
+#define BL_EN_VALUE       GPIO_HIGH
+#endif
+static int rk29_backlight_io_init(void)
+{
+    int ret = 0;
+
+    rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
+       #ifdef  LCD_DISP_ON_PIN
+    rk29_mux_api_set(BL_EN_MUX_NAME, BL_EN_MUX_MODE);
+
+    ret = gpio_request(BL_EN_PIN, NULL);
+    if(ret != 0)
+    {
+        gpio_free(BL_EN_PIN);
+    }
+
+    gpio_direction_output(BL_EN_PIN, 0);
+    gpio_set_value(BL_EN_PIN, BL_EN_VALUE);
+       #endif
+    return ret;
+}
+
+static int rk29_backlight_io_deinit(void)
+{
+    int ret = 0;
+    #ifdef  LCD_DISP_ON_PIN
+    gpio_free(BL_EN_PIN);
+    #endif
+    rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
+    return ret;
+}
+struct rk29_bl_info rk29_bl_info = {
+    .pwm_id   = PWM_ID,
+    .bl_ref   = PWM_EFFECT_VALUE,
+    .io_init   = rk29_backlight_io_init,
+    .io_deinit = rk29_backlight_io_deinit,
+};
+#endif
+/*****************************************************************************************
+* pwm voltage regulator devices
+******************************************************************************************/
+#if defined (CONFIG_RK29_PWM_REGULATOR)
+
+#define REGULATOR_PWM_ID                                       2
+#define REGULATOR_PWM_MUX_NAME                 GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
+#define REGULATOR_PWM_MUX_MODE                                         GPIO2L_PWM2
+#define REGULATOR_PWM_MUX_MODE_GPIO                            GPIO2L_GPIO2A3
+#define REGULATOR_PWM_GPIO                             RK29_PIN2_PA3
+
+static struct regulator_consumer_supply pwm_consumers[] = {
+       {
+               .supply = "vcore",
+       }
+};
+
+static struct regulator_init_data rk29_pwm_regulator_data = {
+       .constraints = {
+               .name = "PWM2",
+               .min_uV =  950000,
+               .max_uV = 1400000,
+               .apply_uV = 1,
+               .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+       },
+       .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
+       .consumer_supplies = pwm_consumers,
+};
+
+static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
+       .pwm_id = REGULATOR_PWM_ID,
+       .pwm_gpio = REGULATOR_PWM_GPIO,
+       //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
+       .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
+       .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
+       .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
+       .init_data  = &rk29_pwm_regulator_data,
+};
+
+static struct platform_device rk29_device_pwm_regulator = {
+       .name = "pwm-voltage-regulator",
+       .id   = -1,
+       .dev  = {
+               .platform_data = &rk29_regulator_pwm_platform_data,
+       },
+};
+
+#endif
+#define POWER_ON_PIN RK29_PIN4_PA4
+#define BP_VOL_PIN       RK29_PIN6_PD3
+
+#if defined(CONFIG_TDSC8800)
+
+static int tdsc8800_io_init(void)
+{
+
+       return 0;
+}
+
+static int tdsc8800_io_deinit(void)
+{
+
+       return 0;
+}
+
+struct rk2818_23d_data rk29_tdsc8800_info = {
+       .io_init = tdsc8800_io_init,
+       .io_deinit = tdsc8800_io_deinit,
+       .bp_power = BP_VOL_PIN,
+       .bp_power_active_low = 1,
+};
+struct platform_device rk29_device_tdsc8800 = {
+        .name = "tdsc8800",
+       .id = -1,
+       .dev            = {
+               .platform_data = &rk29_tdsc8800_info,
+       }
+    };
+#endif
+
+
+/*****************************************************************************************
+ * SDMMC devices
+*****************************************************************************************/
+#if !defined(CONFIG_SDMMC_RK29_OLD)
+static void rk29_sdmmc_gpio_open(int device_id, int on)
+{
+    switch(device_id)
+    {
+        case 0://mmc0
+        {
+            #ifdef CONFIG_SDMMC0_RK29
+            if(on)
+            {
+                gpio_direction_output(RK29_PIN1_PD0,GPIO_HIGH);//set mmc0-clk to high
+                gpio_direction_output(RK29_PIN1_PD1,GPIO_HIGH);//set mmc0-cmd to high.
+                gpio_direction_output(RK29_PIN1_PD2,GPIO_HIGH);//set mmc0-data0 to high.
+                gpio_direction_output(RK29_PIN1_PD3,GPIO_HIGH);//set mmc0-data1 to high.
+                gpio_direction_output(RK29_PIN1_PD4,GPIO_HIGH);//set mmc0-data2 to high.
+                gpio_direction_output(RK29_PIN1_PD5,GPIO_HIGH);//set mmc0-data3 to high.
+
+                mdelay(30);
+            }
+            else
+            {
+                rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_GPIO1_D0);
+                gpio_request(RK29_PIN1_PD0, "mmc0-clk");
+                gpio_direction_output(RK29_PIN1_PD0,GPIO_LOW);//set mmc0-clk to low.
+
+                rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_GPIO1_D1);
+                gpio_request(RK29_PIN1_PD1, "mmc0-cmd");
+                gpio_direction_output(RK29_PIN1_PD1,GPIO_LOW);//set mmc0-cmd to low.
+
+                rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_GPIO1D2);
+                gpio_request(RK29_PIN1_PD2, "mmc0-data0");
+                gpio_direction_output(RK29_PIN1_PD2,GPIO_LOW);//set mmc0-data0 to low.
+
+                rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_GPIO1D3);
+                gpio_request(RK29_PIN1_PD3, "mmc0-data1");
+                gpio_direction_output(RK29_PIN1_PD3,GPIO_LOW);//set mmc0-data1 to low.
+
+                rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_GPIO1D4);
+                gpio_request(RK29_PIN1_PD4, "mmc0-data2");
+                gpio_direction_output(RK29_PIN1_PD4,GPIO_LOW);//set mmc0-data2 to low.
+
+                rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_GPIO1D5);
+                gpio_request(RK29_PIN1_PD5, "mmc0-data3");
+                gpio_direction_output(RK29_PIN1_PD5,GPIO_LOW);//set mmc0-data3 to low.
+
+                mdelay(30);
+            }
+            #endif
+        }
+        break;
+
+        case 1://mmc1
+        {
+            #ifdef CONFIG_SDMMC1_RK29
+            if(on)
+            {
+                gpio_direction_output(RK29_PIN1_PC7,GPIO_HIGH);//set mmc1-clk to high
+                gpio_direction_output(RK29_PIN1_PC2,GPIO_HIGH);//set mmc1-cmd to high.
+                gpio_direction_output(RK29_PIN1_PC3,GPIO_HIGH);//set mmc1-data0 to high.
+                gpio_direction_output(RK29_PIN1_PC4,GPIO_HIGH);//set mmc1-data1 to high.
+                gpio_direction_output(RK29_PIN1_PC5,GPIO_HIGH);//set mmc1-data2 to high.
+                gpio_direction_output(RK29_PIN1_PC6,GPIO_HIGH);//set mmc1-data3 to high.
+                mdelay(100);
+            }
+            else
+            {
+                rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_GPIO1C7);
+                gpio_request(RK29_PIN1_PC7, "mmc1-clk");
+                gpio_direction_output(RK29_PIN1_PC7,GPIO_LOW);//set mmc1-clk to low.
+
+                rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_GPIO1C2);
+                gpio_request(RK29_PIN1_PC2, "mmc1-cmd");
+                gpio_direction_output(RK29_PIN1_PC2,GPIO_LOW);//set mmc1-cmd to low.
+
+                rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_GPIO1C3);
+                gpio_request(RK29_PIN1_PC3, "mmc1-data0");
+                gpio_direction_output(RK29_PIN1_PC3,GPIO_LOW);//set mmc1-data0 to low.
+
+                mdelay(100);
+            }
+            #endif
+        }
+        break;
+
+        case 2: //mmc2
+        break;
+
+        default:
+        break;
+    }
+}
+
+
+static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width)
+{
+    switch (bus_width)
+    {
+
+       case 1://SDMMC_CTYPE_4BIT:
+       {
+               rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
+               rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
+               rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
+       }
+       break;
+
+       case 0x10000://SDMMC_CTYPE_8BIT:
+           break;
+       case 0xFFFF: //gpio_reset
+       {
+            rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);
+            gpio_request(RK29_PIN5_PD5,"sdmmc-power");
+            gpio_direction_output(RK29_PIN5_PD5,GPIO_HIGH); //power-off
+
+            rk29_sdmmc_gpio_open(0, 0);
+
+            gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW); //power-on
+
+            rk29_sdmmc_gpio_open(0, 1);
+       }
+       break;
+
+       default: //case 0://SDMMC_CTYPE_1BIT:
+        {
+               rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
+               rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
+               rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
+
+               rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_GPIO1D3);
+               gpio_request(RK29_PIN1_PD3, "mmc0-data1");
+               gpio_direction_output(RK29_PIN1_PD3,GPIO_HIGH);
+
+               rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_GPIO1D4);
+               gpio_request(RK29_PIN1_PD4, "mmc0-data2");
+               gpio_direction_output(RK29_PIN1_PD4,GPIO_HIGH);
+
+            rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_GPIO1D5);
+            gpio_request(RK29_PIN1_PD5, "mmc0-data3");
+               gpio_direction_output(RK29_PIN1_PD5,GPIO_HIGH);
+       }
+       break;
+       }
+}
+
+static void rk29_sdmmc_set_iomux_mmc1(unsigned int bus_width)
+{
+#if 0
+    switch (bus_width)
+    {
+
+       case 1://SDMMC_CTYPE_4BIT:
+       {
+            rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
+            rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
+            rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
+            rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
+            rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
+            rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
+       }
+       break;
+
+       case 0x10000://SDMMC_CTYPE_8BIT:
+           break;
+       case 0xFFFF:
+       {
+          rk29_sdmmc_gpio_open(1, 0);
+          rk29_sdmmc_gpio_open(1, 1);
+       }
+       break;
+
+       default: //case 0://SDMMC_CTYPE_1BIT:
+        {
+            rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
+               rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
+               rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
+
+            rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_GPIO1C4);
+            gpio_request(RK29_PIN1_PC4, "mmc1-data1");
+               gpio_direction_output(RK29_PIN1_PC4,GPIO_HIGH);
+
+            rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_GPIO1C5);
+            gpio_request(RK29_PIN1_PC5, "mmc1-data2");
+               gpio_direction_output(RK29_PIN1_PC5,GPIO_HIGH);
+
+            rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_GPIO1C6);
+            gpio_request(RK29_PIN1_PC6, "mmc1-data3");
+               gpio_direction_output(RK29_PIN1_PC6,GPIO_HIGH);
+
+       }
+       break;
+       }
+#else
+    rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
+    rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
+    rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
+    rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
+    rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
+    rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
+
+#endif
+}
+
+static void rk29_sdmmc_set_iomux_mmc2(unsigned int bus_width)
+{
+    ;//
+}
+
+static void rk29_sdmmc_set_iomux(int device_id, unsigned int bus_width)
+{
+    switch(device_id)
+    {
+        case 0:
+            #ifdef CONFIG_SDMMC0_RK29
+            rk29_sdmmc_set_iomux_mmc0(bus_width);
+            #endif
+            break;
+        case 1:
+            #ifdef CONFIG_SDMMC1_RK29
+            rk29_sdmmc_set_iomux_mmc1(bus_width);
+            #endif
+            break;
+        case 2:
+            rk29_sdmmc_set_iomux_mmc2(bus_width);
+            break;
+        default:
+            break;
+    }
+}
+#endif
+#ifdef CONFIG_SDMMC0_RK29
+static int rk29_sdmmc0_cfg_gpio(void)
+{
+       rk29_mux_api_set(GPIO1D1_SDMMC0CMD_NAME, GPIO1H_SDMMC0_CMD);
+       rk29_mux_api_set(GPIO1D0_SDMMC0CLKOUT_NAME, GPIO1H_SDMMC0_CLKOUT);
+       rk29_mux_api_set(GPIO1D2_SDMMC0DATA0_NAME, GPIO1H_SDMMC0_DATA0);
+       rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
+       rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
+       rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
+#ifdef CONFIG_SDMMC_RK29_OLD
+       rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2);
+#else
+  rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw.
+#endif
+       rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5);   ///GPIO5H_SDMMC0_PWR_EN);  ///GPIO5H_GPIO5D5);
+       gpio_request(RK29_PIN5_PD5,"sdmmc");
+       gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
+       mdelay(100);
+       gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
+       return 0;
+}
+
+#define CONFIG_SDMMC0_USE_DMA
+struct rk29_sdmmc_platform_data default_sdmmc0_data = {
+       .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
+                                          MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|
+                                          MMC_VDD_33_34|MMC_VDD_34_35| MMC_VDD_35_36),
+       .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
+       .io_init = rk29_sdmmc0_cfg_gpio,
+       .dma_name = "sd_mmc",
+#ifdef CONFIG_SDMMC0_USE_DMA
+       .use_dma  = 1,
+#else
+       .use_dma = 0,
+#endif
+#if !defined(CONFIG_SDMMC_RK29_OLD)
+  .set_iomux = rk29_sdmmc_set_iomux,
+#endif
+
+//     .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO
+       .detect_irq = INVALID_GPIO,
+       .enable_sd_wakeup = 0,
+};
+#endif
+#ifdef CONFIG_SDMMC1_RK29
+#define CONFIG_SDMMC1_USE_DMA
+static int rk29_sdmmc1_cfg_gpio(void)
+{
+       rk29_mux_api_set(GPIO1C2_SDMMC1CMD_NAME, GPIO1H_SDMMC1_CMD);
+       rk29_mux_api_set(GPIO1C7_SDMMC1CLKOUT_NAME, GPIO1H_SDMMC1_CLKOUT);
+       rk29_mux_api_set(GPIO1C3_SDMMC1DATA0_NAME, GPIO1H_SDMMC1_DATA0);
+       rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_SDMMC1_DATA1);
+       rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_SDMMC1_DATA2);
+       rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_SDMMC1_DATA3);
+       //rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_SDMMC1_DETECT_N);
+       return 0;
+}
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+static int rk29sdk_wifi_status(struct device *dev);
+static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
+#endif
+
+#define RK29SDK_WIFI_SDIO_CARD_DETECT_N    RK29_PIN1_PD6
+
+struct rk29_sdmmc_platform_data default_sdmmc1_data = {
+       .host_ocr_avail = (MMC_VDD_25_26|MMC_VDD_26_27|MMC_VDD_27_28|MMC_VDD_28_29|
+                                          MMC_VDD_29_30|MMC_VDD_30_31|MMC_VDD_31_32|
+                                          MMC_VDD_32_33|MMC_VDD_33_34),
+       .host_caps      = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ|
+                                  MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED),
+       .io_init = rk29_sdmmc1_cfg_gpio,
+       .dma_name = "sdio",
+#ifdef CONFIG_SDMMC1_USE_DMA
+       .use_dma  = 1,
+#else
+       .use_dma = 0,
+#endif
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+        .status = rk29sdk_wifi_status,
+        .register_status_notify = rk29sdk_wifi_status_register,
+#endif
+#if 0
+        .detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N,
+#endif
+#if !defined(CONFIG_SDMMC_RK29_OLD)
+    .set_iomux = rk29_sdmmc_set_iomux,
+#endif
+};
+#endif
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+#define RK29SDK_WIFI_BT_GPIO_POWER_N       RK29_PIN5_PD6
+#define RK29SDK_WIFI_GPIO_RESET_N          RK29_PIN6_PC0
+#define RK29SDK_BT_GPIO_RESET_N            RK29_PIN6_PC7
+
+static int rk29sdk_wifi_cd = 0;   /* wifi virtual 'card detect' status */
+static void (*wifi_status_cb)(int card_present, void *dev_id);
+static void *wifi_status_cb_devid;
+int rk29sdk_wifi_power_state = 0;
+int rk29sdk_bt_power_state = 0;
+
+static int rk29sdk_wifi_status(struct device *dev)
+{
+        return rk29sdk_wifi_cd;
+}
+
+static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void *dev_id), void *dev_id)
+{
+        if(wifi_status_cb)
+                return -EAGAIN;
+        wifi_status_cb = callback;
+        wifi_status_cb_devid = dev_id;
+        return 0;
+}
+
+static int rk29sdk_wifi_bt_gpio_control_init(void)
+{
+    if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
+           pr_info("%s: request wifi_bt power gpio failed\n", __func__);
+           return -1;
+    }
+
+    if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
+           pr_info("%s: request wifi reset gpio failed\n", __func__);
+           gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
+           return -1;
+    }
+
+    if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
+          pr_info("%s: request bt reset gpio failed\n", __func__);
+          gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
+          return -1;
+    }
+
+    gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
+    gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N,    GPIO_LOW);
+    gpio_direction_output(RK29SDK_BT_GPIO_RESET_N,      GPIO_LOW);
+
+    pr_info("%s: init finished\n",__func__);
+
+    return 0;
+}
+
+static int rk29sdk_wifi_power(int on)
+{
+        pr_info("%s: %d\n", __func__, on);
+        if (on){
+                gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
+                gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
+                mdelay(100);
+                pr_info("wifi turn on power\n");
+        }else{
+                if (!rk29sdk_bt_power_state){
+                        gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
+                        mdelay(100);
+                        pr_info("wifi shut off power\n");
+                }else
+                {
+                        pr_info("wifi shouldn't shut off power, bt is using it!\n");
+                }
+                gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
+
+        }
+
+        rk29sdk_wifi_power_state = on;
+        return 0;
+}
+
+static int rk29sdk_wifi_reset_state;
+static int rk29sdk_wifi_reset(int on)
+{
+        pr_info("%s: %d\n", __func__, on);
+        gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, on);
+        mdelay(100);
+        rk29sdk_wifi_reset_state = on;
+        return 0;
+}
+
+int rk29sdk_wifi_set_carddetect(int val)
+{
+        pr_info("%s:%d\n", __func__, val);
+        rk29sdk_wifi_cd = val;
+        if (wifi_status_cb){
+                wifi_status_cb(val, wifi_status_cb_devid);
+        }else {
+                pr_warning("%s, nobody to notify\n", __func__);
+        }
+        return 0;
+}
+EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
+
+static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
+        {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
+        {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
+        {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
+        {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
+};
+
+static void *rk29sdk_mem_prealloc(int section, unsigned long size)
+{
+        if (section == PREALLOC_WLAN_SEC_NUM)
+                return wlan_static_skb;
+
+        if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
+                return NULL;
+
+        if (wifi_mem_array[section].size < size)
+                return NULL;
+
+        return wifi_mem_array[section].mem_ptr;
+}
+
+int __init rk29sdk_init_wifi_mem(void)
+{
+        int i;
+        int j;
+
+        for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
+                wlan_static_skb[i] = dev_alloc_skb(
+                                ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
+
+                if (!wlan_static_skb[i])
+                        goto err_skb_alloc;
+        }
+
+        for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
+                wifi_mem_array[i].mem_ptr =
+                                kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
+
+                if (!wifi_mem_array[i].mem_ptr)
+                        goto err_mem_alloc;
+        }
+        return 0;
+
+ err_mem_alloc:
+        pr_err("Failed to mem_alloc for WLAN\n");
+        for (j = 0 ; j < i ; j++)
+                kfree(wifi_mem_array[j].mem_ptr);
+
+        i = WLAN_SKB_BUF_NUM;
+
+ err_skb_alloc:
+        pr_err("Failed to skb_alloc for WLAN\n");
+        for (j = 0 ; j < i ; j++)
+                dev_kfree_skb(wlan_static_skb[j]);
+
+        return -ENOMEM;
+}
+
+static struct wifi_platform_data rk29sdk_wifi_control = {
+        .set_power = rk29sdk_wifi_power,
+        .set_reset = rk29sdk_wifi_reset,
+        .set_carddetect = rk29sdk_wifi_set_carddetect,
+        .mem_prealloc   = rk29sdk_mem_prealloc,
+};
+static struct platform_device rk29sdk_wifi_device = {
+        .name = "bcm4329_wlan",
+        .id = 1,
+        .dev = {
+                .platform_data = &rk29sdk_wifi_control,
+         },
+};
+#endif
+
+
+/* bluetooth rfkill device */
+static struct platform_device rk29sdk_rfkill = {
+        .name = "rk29sdk_rfkill",
+        .id = -1,
+};
+
+
+#ifdef CONFIG_VIVANTE
+static struct resource resources_gpu[] = {
+    [0] = {
+               .name   = "gpu_irq",
+        .start         = IRQ_GPU,
+        .end    = IRQ_GPU,
+        .flags  = IORESOURCE_IRQ,
+    },
+    [1] = {
+               .name = "gpu_base",
+        .start  = RK29_GPU_PHYS,
+        .end    = RK29_GPU_PHYS + RK29_GPU_SIZE - 1,
+        .flags  = IORESOURCE_MEM,
+    },
+    [2] = {
+               .name = "gpu_mem",
+        .start  = PMEM_GPU_BASE,
+        .end    = PMEM_GPU_BASE + PMEM_GPU_SIZE - 1,
+        .flags  = IORESOURCE_MEM,
+    },
+};
+static struct platform_device rk29_device_gpu = {
+    .name             = "galcore",
+    .id               = 0,
+    .num_resources    = ARRAY_SIZE(resources_gpu),
+    .resource         = resources_gpu,
+};
+#endif
+#ifdef CONFIG_KEYS_RK29
+extern struct rk29_keys_platform_data rk29_keys_pdata;
+static struct platform_device rk29_device_keys = {
+       .name           = "rk29-keypad",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &rk29_keys_pdata,
+       },
+};
+#endif
+
+#ifdef CONFIG_USE_GPIO_GENERATE_WAVE
+static struct gpio_wave_platform_data gpio_wave_pdata = {
+       .gpio = RK29_PIN0_PA0,
+       .Htime = 2000,
+       .Ltime = 300,
+       .Dvalue = GPIO_HIGH,
+};
+static struct platform_device gpio_wave_device = {
+       .name           = "gpio_wave",
+       .id     = -1,
+       .dev            = {
+               .platform_data  = &gpio_wave_pdata,
+       },
+};
+#endif
+#if CONFIG_ANDROID_TIMED_GPIO
+static struct timed_gpio timed_gpios[] = {
+       {
+               .name = "vibrator",
+               .gpio = RK29_PIN1_PB5,
+               .max_timeout = 1000,
+               .active_low = 0,
+               .adjust_time =20,      //adjust for diff product
+       },
+};
+
+struct timed_gpio_platform_data rk29_vibrator_info = {
+       .num_gpios = 1,
+       .gpios = timed_gpios,
+};
+
+struct platform_device rk29_device_vibrator ={
+       .name = "timed-gpio",
+       .id = -1,
+       .dev = {
+               .platform_data = &rk29_vibrator_info,
+               },
+
+};
+#endif
+#ifdef CONFIG_BUTTON_LIGHT
+static int rk29_buttonlight_io_init(void)
+{
+    int ret = 0;
+
+    return ret;
+}
+
+static int rk29_buttonlight_io_deinit(void)
+{
+    int ret = 0;
+    return ret;
+}
+struct rk29_button_light_info rk29_button_light_info = {
+       .led_on_pin = RK29_PIN0_PA0,
+       .led_on_level = 1,
+       .io_init = rk29_buttonlight_io_init,
+       .io_deinit = rk29_buttonlight_io_deinit,
+
+};
+#endif
+static void __init rk29_board_iomux_init(void)
+{
+       int err;
+       #ifdef CONFIG_UART1_RK29
+       //disable uart1 pull down
+       rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_GPIO2A5);
+       rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_GPIO2A4);
+
+       gpio_request(RK29_PIN2_PA5, NULL);
+       gpio_request(RK29_PIN2_PA4, NULL);
+
+       gpio_pull_updown(RK29_PIN2_PA5, PullDisable);
+       gpio_pull_updown(RK29_PIN2_PA4, PullDisable);
+
+       rk29_mux_api_set(GPIO2A5_UART1SOUT_NAME, GPIO2L_UART1_SOUT);
+       rk29_mux_api_set(GPIO2A4_UART1SIN_NAME, GPIO2L_UART1_SIN);
+
+       gpio_free(RK29_PIN2_PA5);
+       gpio_free(RK29_PIN2_PA4);
+    #endif
+       #if CONFIG_ANDROID_TIMED_GPIO
+       rk29_mux_api_set(GPIO1B5_PWM0_NAME, GPIO1L_GPIO1B5);//for timed gpio
+       #endif
+       #ifdef CONFIG_RK29_PWM_REGULATOR
+       rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
+       #endif
+       rk29_mux_api_set(GPIO4C0_RMIICLKOUT_RMIICLKIN_NAME,GPIO4H_GPIO4C0);
+
+/****************************clock change********************************************/
+       err = gpio_request(RK29_PIN4_PC0, "clk27M_control");
+       if (err) {
+               gpio_free(RK29_PIN4_PC0);
+               printk("-------request RK29_PIN4_PC0 fail--------\n");
+               return -1;
+       }
+       //phy power down
+       gpio_direction_output(RK29_PIN4_PC0, GPIO_LOW);// 27M  32K
+       gpio_set_value(RK29_PIN4_PC0, GPIO_LOW);
+
+       rk29_mux_api_set(GPIO4C5_RMIICSRDVALID_MIIRXDVALID_NAME,GPIO4H_GPIO4C5);
+
+       err = gpio_request(RK29_PIN4_PC5, "clk24M_control");
+       if (err) {
+               gpio_free(RK29_PIN4_PC5);
+               printk("-------request RK29_PIN4_PC5 fail--------\n");
+               return -1;
+       }
+       //phy power down
+       gpio_direction_output(RK29_PIN4_PC5, GPIO_LOW);// control 24M
+       gpio_set_value(RK29_PIN4_PC5, GPIO_LOW);
+/*******************************************************************/
+
+
+}
+
+// For phone,just a disk only, add by phc,20110816
+#ifdef CONFIG_USB_ANDROID
+struct usb_mass_storage_platform_data phone_mass_storage_pdata = {
+       .nluns          = 1,
+       .vendor         = "RockChip",
+       .product        = "rk29 sdk",
+       .release        = 0x0100,
+};
+
+//static
+struct platform_device phone_usb_mass_storage_device = {
+       .name   = "usb_mass_storage",
+       .id     = -1,
+       .dev    = {
+               .platform_data = &phone_mass_storage_pdata,
+       },
+};
+#endif
+
+#ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND
+
+struct platform_device charge_lowerpower_device = {
+       .name   = "charge_lowerpower",
+       .id     = -1,
+};
+#endif
+
+static struct platform_device *devices[] __initdata = {
+
+#ifdef CONFIG_RK29_WATCHDOG
+       &rk29_device_wdt,
+#endif
+
+#ifdef CONFIG_UART1_RK29
+       &rk29_device_uart1,
+#endif
+#ifdef CONFIG_UART0_RK29
+       &rk29_device_uart0,
+#endif
+#ifdef CONFIG_UART2_RK29
+       &rk29_device_uart2,
+#endif
+#ifdef CONFIG_UART3_RK29
+       &rk29_device_uart3,
+#endif
+
+#ifdef CONFIG_RK29_PWM_REGULATOR
+       &rk29_device_pwm_regulator,
+#endif
+#ifdef CONFIG_SPIM0_RK29
+    &rk29xx_device_spi0m,
+#endif
+#ifdef CONFIG_SPIM1_RK29
+    &rk29xx_device_spi1m,
+#endif
+#ifdef CONFIG_ADC_RK29
+       &rk29_device_adc,
+#endif
+#ifdef CONFIG_I2C0_RK29
+       &rk29_device_i2c0,
+#endif
+#ifdef CONFIG_I2C1_RK29
+       &rk29_device_i2c1,
+#endif
+#ifdef CONFIG_I2C2_RK29
+       &rk29_device_i2c2,
+#endif
+#ifdef CONFIG_I2C3_RK29
+       &rk29_device_i2c3,
+#endif
+
+#ifdef CONFIG_SND_RK29_SOC_I2S_2CH
+        &rk29_device_iis_2ch,
+#endif
+#ifdef CONFIG_SND_RK29_SOC_I2S_8CH
+        &rk29_device_iis_8ch,
+#endif
+
+#ifdef CONFIG_KEYS_RK29
+       &rk29_device_keys,
+#endif
+#ifdef CONFIG_USE_GPIO_GENERATE_WAVE
+       &gpio_wave_device,
+#endif
+#ifdef CONFIG_SDMMC0_RK29
+       &rk29_device_sdmmc0,
+#endif
+#ifdef CONFIG_SDMMC1_RK29
+       &rk29_device_sdmmc1,
+#endif
+
+#ifdef CONFIG_MTD_NAND_RK29XX
+       &rk29xx_device_nand,
+#endif
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+        &rk29sdk_wifi_device,
+#endif
+
+#ifdef CONFIG_BT
+        &rk29sdk_rfkill,
+#endif
+
+#if defined(CONFIG_TDSC8800)
+       &rk29_device_tdsc8800,
+#endif
+
+#ifdef CONFIG_MTD_NAND_RK29
+       &rk29_device_nand,
+#endif
+
+#ifdef CONFIG_FB_RK29
+       &rk29_device_fb,
+       &rk29_device_dma_cpy,
+#endif
+#ifdef CONFIG_BACKLIGHT_RK29_BL
+       &rk29_device_backlight,
+#endif
+#ifdef CONFIG_BUTTON_LIGHT
+       &rk29_device_buttonlight,
+#endif
+#ifdef CONFIG_RK29_VMAC
+       &rk29_device_vmac,
+#endif
+#ifdef CONFIG_VIVANTE
+       &rk29_device_gpu,
+#endif
+#ifdef CONFIG_VIDEO_RK29
+       &rk29_device_camera,      /* ddl@rock-chips.com : camera support  */
+       #if (CONFIG_SENSOR_IIC_ADDR_0 != 0x00)
+       &rk29_soc_camera_pdrv_0,
+       #endif
+       &rk29_soc_camera_pdrv_1,
+       &android_pmem_cam_device,
+#endif
+       &android_pmem_device,
+       &rk29_vpu_mem_device,
+#ifdef CONFIG_USB20_OTG
+       &rk29_device_usb20_otg,
+#endif
+#ifdef CONFIG_USB20_HOST
+       &rk29_device_usb20_host,
+#endif
+#ifdef CONFIG_USB11_HOST
+       &rk29_device_usb11_host,
+#endif
+#ifdef CONFIG_USB_ANDROID
+       &android_usb_device,
+       &phone_usb_mass_storage_device,
+#endif
+#ifdef CONFIG_RK29_IPP
+       &rk29_device_ipp,
+#endif
+#ifdef CONFIG_VIDEO_RK29XX_VOUT
+       &rk29_v4l2_output_devce,
+#endif
+#ifdef CONFIG_RK_HEADSET_DET
+    &rk_device_headset,
+#endif
+#ifdef CONFIG_RK29_GPS
+       &rk29_device_gps,
+#endif
+#ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND
+       &charge_lowerpower_device,
+#endif
+#ifdef CONFIG_ANDROID_TIMED_GPIO
+       &rk29_device_vibrator,
+#endif
+};
+
+#ifdef CONFIG_RK29_VMAC
+/*****************************************************************************************
+ * vmac devices
+ * author: lyx@rock-chips.com
+ *****************************************************************************************/
+static int rk29_vmac_register_set(void)
+{
+       //config rk29 vmac as rmii, 100MHz
+       u32 value= readl(RK29_GRF_BASE + 0xbc);
+       value = (value & 0xfff7ff) | (0x400);
+       writel(value, RK29_GRF_BASE + 0xbc);
+       return 0;
+}
+
+static int rk29_rmii_io_init(void)
+{
+       int err;
+
+       //phy power gpio
+       err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
+       if (err) {
+               gpio_free(RK29_PIN6_PB0);
+               printk("-------request RK29_PIN6_PB0 fail--------\n");
+               return -1;
+       }
+       //phy power down
+       gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
+       gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
+
+       return 0;
+}
+
+static int rk29_rmii_io_deinit(void)
+{
+       //phy power down
+       gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
+       gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
+       //free
+       gpio_free(RK29_PIN6_PB0);
+       return 0;
+}
+
+static int rk29_rmii_power_control(int enable)
+{
+       if (enable) {
+               //enable phy power
+               gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
+               gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
+       }
+       else {
+               gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
+               gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
+       }
+       return 0;
+}
+
+struct rk29_vmac_platform_data rk29_vmac_pdata = {
+       .vmac_register_set = rk29_vmac_register_set,
+       .rmii_io_init = rk29_rmii_io_init,
+       .rmii_io_deinit = rk29_rmii_io_deinit,
+       .rmii_power_control = rk29_rmii_power_control,
+};
+#endif
+
+/*****************************************************************************************
+ * spi devices
+ * author: cmc@rock-chips.com
+ *****************************************************************************************/
+#define SPI_CHIPSELECT_NUM 2
+static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
+    {
+               .name = "spi0 cs0",
+               .cs_gpio = RK29_PIN2_PC1,
+               .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
+               .cs_iomux_mode = GPIO2H_SPI0_CSN0,
+       },
+       {
+               .name = "spi0 cs1",
+               .cs_gpio = RK29_PIN1_PA4,
+               .cs_iomux_name = GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME,//if no iomux,set it NULL
+               .cs_iomux_mode = GPIO1L_SPI0_CSN1,
+       }
+};
+
+static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
+    {
+               .name = "spi1 cs0",
+               .cs_gpio = RK29_PIN2_PC5,
+               .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
+               .cs_iomux_mode = GPIO2H_SPI1_CSN0,
+       },
+       {
+               .name = "spi1 cs1",
+               .cs_gpio = RK29_PIN1_PA3,
+               .cs_iomux_name = GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,//if no iomux,set it NULL
+               .cs_iomux_mode = GPIO1L_SPI1_CSN1,
+       }
+};
+
+static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
+{
+#if 1
+               int i;
+               if (cs_gpios) {
+                       for (i=0; i<cs_num; i++) {
+                               rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
+                       }
+               }
+#endif
+       return 0;
+}
+
+static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
+{
+       return 0;
+}
+
+static int spi_io_fix_leakage_bug(void)
+{
+#if 0
+       gpio_direction_output(RK29_PIN2_PC1, GPIO_LOW);
+#endif
+       return 0;
+}
+
+static int spi_io_resume_leakage_bug(void)
+{
+#if 0
+       gpio_direction_output(RK29_PIN2_PC1, GPIO_HIGH);
+#endif
+       return 0;
+}
+
+struct rk29xx_spi_platform_data rk29xx_spi0_platdata = {
+       .num_chipselect = SPI_CHIPSELECT_NUM,
+       .chipselect_gpios = rk29xx_spi0_cs_gpios,
+       .io_init = spi_io_init,
+       .io_deinit = spi_io_deinit,
+       .io_fix_leakage_bug = spi_io_fix_leakage_bug,
+       .io_resume_leakage_bug = spi_io_resume_leakage_bug,
+};
+
+struct rk29xx_spi_platform_data rk29xx_spi1_platdata = {
+       .num_chipselect = SPI_CHIPSELECT_NUM,
+       .chipselect_gpios = rk29xx_spi1_cs_gpios,
+       .io_init = spi_io_init,
+       .io_deinit = spi_io_deinit,
+       .io_fix_leakage_bug = spi_io_fix_leakage_bug,
+       .io_resume_leakage_bug = spi_io_resume_leakage_bug,
+};
+
+/*****************************************************************************************
+ * xpt2046 touch panel
+ * author: hhb@rock-chips.com
+ *****************************************************************************************/
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI)
+#define XPT2046_GPIO_INT           RK29_PIN4_PD5 //中断???#define DEBOUNCE_REPTIME  3
+
+static struct xpt2046_platform_data xpt2046_info = {
+       .model                  = 2046,
+       .keep_vref_on   = 1,
+       .swap_xy                = 0,
+       .debounce_max           = 7,
+       .debounce_rep           = DEBOUNCE_REPTIME,
+       .debounce_tol           = 20,
+       .gpio_pendown           = XPT2046_GPIO_INT,
+       .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+       .pendown_iomux_mode = GPIO4H_GPIO4D5,
+       .touch_virtualkey_length = 60,
+       .penirq_recheck_delay_usecs = 1,
+#if defined(CONFIG_TOUCHSCREEN_480X800)
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .touch_ad_top = 3940,
+       .touch_ad_bottom = 310,
+       .touch_ad_left = 3772,
+       .touch_ad_right = 340,
+#elif defined(CONFIG_TOUCHSCREEN_800X480)
+       .x_min                  = 0,
+       .x_max                  = 800,
+       .y_min                  = 0,
+       .y_max                  = 480,
+       .touch_ad_top = 2447,
+       .touch_ad_bottom = 207,
+       .touch_ad_left = 5938,
+       .touch_ad_right = 153,
+#elif defined(CONFIG_TOUCHSCREEN_320X480)
+       .x_min                  = 0,
+       .x_max                  = 320,
+       .y_min                  = 0,
+       .y_max                  = 480,
+       .touch_ad_top = 3166,
+       .touch_ad_bottom = 256,
+       .touch_ad_left = 3658,
+       .touch_ad_right = 380,
+#endif
+};
+#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI)
+static struct xpt2046_platform_data xpt2046_info = {
+       .model                  = 2046,
+       .keep_vref_on   = 1,
+       .swap_xy                = 0,
+       .debounce_max           = 7,
+       .debounce_rep           = DEBOUNCE_REPTIME,
+       .debounce_tol           = 20,
+       .gpio_pendown           = XPT2046_GPIO_INT,
+       .pendown_iomux_name = GPIO4D5_CPUTRACECTL_NAME,
+       .pendown_iomux_mode = GPIO4H_GPIO4D5,
+       .touch_virtualkey_length = 60,
+       .penirq_recheck_delay_usecs = 1,
+
+#if defined(CONFIG_TOUCHSCREEN_480X800)
+       .x_min                  = 0,
+       .x_max                  = 480,
+       .y_min                  = 0,
+       .y_max                  = 800,
+       .screen_x = { 70,  410, 70, 410, 240},
+       .screen_y = { 50, 50,  740, 740, 400},
+       .uncali_x_default = {  3267,  831, 3139, 715, 1845 },
+       .uncali_y_default = { 3638,  3664, 564,  591, 2087 },
+#elif defined(CONFIG_TOUCHSCREEN_800X480)
+       .x_min                  = 0,
+       .x_max                  = 800,
+       .y_min                  = 0,
+       .y_max                  = 480,
+       .screen_x[5] = { 50, 750,  50, 750, 400};
+       .screen_y[5] = { 40,  40, 440, 440, 240};
+       .uncali_x_default[5] = { 438,  565, 3507,  3631, 2105 };
+       .uncali_y_default[5] = {  3756,  489, 3792, 534, 2159 };
+#elif defined(CONFIG_TOUCHSCREEN_320X480)
+       .x_min                  = 0,
+       .x_max                  = 320,
+       .y_min                  = 0,
+       .y_max                  = 480,
+       .screen_x[5] = { 50, 270,  50, 270, 160};
+       .screen_y[5] = { 40,  40, 440, 440, 240};
+       .uncali_x_default[5] = { 812,  3341, 851,  3371, 2183 };
+       .uncali_y_default[5] = {  442,  435, 3193, 3195, 2004 };
+#endif
+};
+#endif
+
+#if defined(CONFIG_RK29_SC8800)
+static struct plat_sc8800 sc8800_plat_data = {
+       .slav_rts_pin = RK29_PIN1_PC1,
+       .slav_rdy_pin = RK29_PIN0_PA3,
+       .master_rts_pin = RK29_PIN1_PC0,
+       .master_rdy_pin = RK29_PIN0_PA2,
+       //.poll_time = 100,
+};
+#endif
+/*
+static struct rk29xx_spi_chip cmb_spi_chip = {
+       .transfer_mode = rk29xx_SPI_FULL_DUPLEX,
+};
+*/
+/*****************************************************************************************
+ * CMMB IO CONFIG
+ * author: lby@rock-chips.com
+ *****************************************************************************************/
+#if defined(CONFIG_SMS_SPI_ROCKCHIP)
+#define CMMB_1186_SPIIRQ RK29_PIN6_PD1
+void cmmb_io_init_mux(void)
+{
+//     rk29_mux_api_set(GPIO1A4_EMMCWRITEPRT_SPI0CS1_NAME, GPIO1L_GPIO1A4);
+
+}
+void cmmb_io_set_for_pm(void)
+{
+       printk("entering cmmb_io_set_for_pm\n");
+       gpio_request(RK29_PIN6_PD2, NULL);//cmmb reset pin
+       gpio_direction_output(RK29_PIN6_PD2,0);
+       rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_GPIO1A3);
+       gpio_request(RK29_PIN1_PA3, NULL);//cmmb cs pin
+       gpio_direction_input(RK29_PIN1_PA3);
+       gpio_pull_updown(RK29_PIN1_PA3, 0);
+}
+
+void cmmb_power_on_by_wm831x(void)
+{
+       struct regulator *ldo;
+
+       printk("entering cmmb_power_on_by_wm831x\n");
+
+       rk29_mux_api_set(GPIO1A3_EMMCDETECTN_SPI1CS1_NAME,GPIO1L_SPI0_CSN1);
+       gpio_request(RK29_PIN6_PD2, NULL);
+       gpio_direction_output(RK29_PIN6_PD2,0);
+       mdelay(200);
+
+       ldo = regulator_get(NULL, "ldo8");              //cmmb
+       regulator_set_voltage(ldo,1200000,1200000);
+       regulator_set_suspend_voltage(ldo,1200000);
+       regulator_enable(ldo);
+       printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo9");              //cmmb
+       regulator_set_voltage(ldo,3000000,3000000);
+       regulator_set_suspend_voltage(ldo,3000000);
+       regulator_enable(ldo);
+       printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo));
+       regulator_put(ldo);
+
+       mdelay(200);
+       gpio_direction_output(RK29_PIN6_PD2,1);
+}
+
+void cmmb_power_down_by_wm831x(void)
+{
+       struct regulator* ldo;
+
+       printk("entering cmmb_power_down_by_wm831x\n");
+
+       ldo = regulator_get(NULL, "ldo8");
+       regulator_set_voltage(ldo,0,0);
+       regulator_disable(ldo);
+       regulator_put(ldo);
+
+       ldo = regulator_get(NULL, "ldo9");
+       regulator_set_voltage(ldo,0,0);
+       regulator_disable(ldo);
+       regulator_put(ldo);
+}
+
+static struct cmmb_io_def_s cmmb_io = {
+       .cmmb_pw_en = INVALID_GPIO,
+       .cmmb_pw_dwn = INVALID_GPIO,
+       .cmmb_pw_rst = RK29_PIN6_PD2,
+       .cmmb_irq = CMMB_1186_SPIIRQ,
+       .io_init_mux = cmmb_io_init_mux,
+       .cmmb_io_pm = cmmb_io_set_for_pm,
+       .cmmb_power_on = cmmb_power_on_by_wm831x,
+       .cmmb_power_down = cmmb_power_down_by_wm831x
+};
+#endif
+static struct spi_board_info board_spi_devices[] = {
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
+       {
+               .modalias       = "xpt2046_ts",
+               .chip_select    = 0,// 2,
+               .max_speed_hz   = 125 * 1000 * 26,/* (max sample rate @ 3V) * (cmd + data + overhead) */
+               .bus_num        = 0,
+               .irq = XPT2046_GPIO_INT,
+               .platform_data = &xpt2046_info,
+       },
+#endif
+
+#if defined(CONFIG_MFD_WM831X_SPI)
+       {
+               .modalias       = "wm8310",
+               .chip_select    = 1,
+               .max_speed_hz   = 1*1000*1000,
+               .bus_num        = 1,
+               .irq            = RK29_PIN4_PD0,
+               .platform_data = &wm831x_platdata,
+       },
+#endif
+#if defined(CONFIG_RK29_SC8800)
+       {
+               .modalias  = "sc8800",
+               .bus_num = 0,
+               .platform_data = &sc8800_plat_data,
+               .max_speed_hz  = 12*1000*1000,
+               .chip_select   = 0,
+       },
+#endif
+
+#if defined(CONFIG_SMS_SPI_ROCKCHIP)
+       {
+               .modalias       = "siano1186",
+               .chip_select    = 1,
+               .max_speed_hz   = 12*1000*1000,
+               .bus_num        = 1,
+               .irq            =CMMB_1186_SPIIRQ,
+               //.controller_data = &cmb_spi_chip,
+               .platform_data = &cmmb_io,
+       },
+#endif
+};
+
+
+/**********************************************************************************************
+ *
+ * The virtual keys for android "back", "home", "menu", "search", these four keys are touch key
+ * on the touch screen panel. (added by hhb@rock-chips.com 2011.03.31)
+ *
+ ***********************************************************************************************/
+static ssize_t rk29xx_virtual_keys_show(struct kobject *kobj,
+                       struct kobj_attribute *attr, char *buf)
+{
+#if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
+       || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)\
+       || defined(CONFIG_TOUCHSCREEN_PIXCIR)
+       /* center: x: home: 50, menu: 184, back: 315, search 435, y: 830*/
+    /* centerx;centery;width;height; */
+       return sprintf(buf,
+               __stringify(EV_KEY) ":" __stringify(KEY_BACK)        ":305:845:50:60"//":305:845:50:60"     //":50:830:98:50"  //":210:796:98:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)   ":165:845:50:60"//":165:845:50:60"   // ":184:830:120:50"  // ":435:796:120:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME)   ":25:845:120:60"//":25:845:50:60"   //":315:830:100:50"  //":320:796:100:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":445:845:50:60"//":445:845:50:60"   //":50:815:98:50"    //   //":85:796:88:50"
+               "\n");
+#endif
+#if defined(CONFIG_TOUCHSCREEN_FT5X0X) || defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
+       return sprintf(buf,
+               __stringify(EV_KEY) ":" __stringify(KEY_BACK)        ":305:875:60:60"//":305:845:50:60"     //":50:830:98:50"  //":210:796:98:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU)   ":165:875:60:60"//":165:845:50:60"   // ":184:830:120:50"  // ":435:796:120:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME)   ":30:875:60:60"//":25:845:50:60"   //":315:830:100:50"  //":320:796:100:50"
+               ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":445:875:60:60"//":445:845:50:60"   //":50:815:98:50"    //   //":85:796:88:50"
+               "\n");
+#endif
+       return 0;
+}
+
+static struct kobj_attribute rk29xx_virtual_keys_attr = {
+       .attr = {
+#if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI)
+               .name = "virtualkeys.xpt2046-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_HX8520_IIC)
+        .name = "virtualkeys.hx8520-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_GT801_IIC)
+               .name = "virtualkeys.gt801-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
+               .name = "virtualkeys.ili2102-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_FT5X0X)
+               .name = "virtualkeys.ft5x0x_ts-touchscreen",
+#elif defined(CONFIG_TOUCHSCREEN_PIXCIR)
+               .name = "virtualkeys.pixcir_ts-touchscreen",
+#else
+               .name = "virtualkeys",
+#endif
+               .mode = S_IRUGO,
+       },
+       .show = &rk29xx_virtual_keys_show,
+};
+
+static struct attribute *rk29xx_properties_attrs[] = {
+       &rk29xx_virtual_keys_attr.attr,
+       NULL
+};
+
+static struct attribute_group rk29xx_properties_attr_group = {
+       .attrs = rk29xx_properties_attrs,
+};
+static int rk29xx_virtual_keys_init(void)
+{
+       int ret;
+       struct kobject *properties_kobj;
+       printk("rk29xx_virtual_keys_init \n");
+       properties_kobj = kobject_create_and_add("board_properties", NULL);
+       if (properties_kobj)
+               ret = sysfs_create_group(properties_kobj,
+                               &rk29xx_properties_attr_group);
+       if (!properties_kobj || ret)
+       {
+               pr_err("failed to create board_properties\n");
+       }
+       return ret;
+}
+
+
+static void __init rk29_gic_init_irq(void)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38))
+       gic_init(0, 32, (void __iomem *)RK29_GICPERI_BASE, (void __iomem *)RK29_GICCPU_BASE);
+#else
+       gic_dist_init(0, (void __iomem *)RK29_GICPERI_BASE, 32);
+       gic_cpu_init(0, (void __iomem *)RK29_GICCPU_BASE);
+#endif
+}
+
+static void __init machine_rk29_init_irq(void)
+{
+       rk29_gic_init_irq();
+       rk29_gpio_init();
+}
+
+
+
+static void rk29_pm_power_restart(void)
+{
+       printk("%s,line=%d\n",__FUNCTION__,__LINE__);
+       mdelay(2);
+#if defined(CONFIG_MFD_WM831X)
+       wm831x_device_restart(gWm831x);
+#endif
+
+}
+
+static void rk29_pm_power_off(void)
+{
+       printk(KERN_ERR "rk29_pm_power_off start...\n");
+       gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
+       gpio_direction_output(BP_VOL_PIN,GPIO_LOW);
+#if defined(CONFIG_MFD_WM831X)
+       if(wm831x_read_usb(gWm831x))
+       rk29_pm_power_restart();        //if charging then restart
+       else
+       wm831x_device_shutdown(gWm831x);//else shutdown
+#endif
+       while (1);
+}
+
+static struct cpufreq_frequency_table freq_table[] =
+{
+       { .index = 1100000, .frequency =  408000 },
+       { .index = 1150000, .frequency =  600000 },
+       { .index = 1200000, .frequency =  816000 },
+//     { .index = 1300000, .frequency = 1008000 },
+       { .frequency = CPUFREQ_TABLE_END },
+};
+
+static void __init machine_rk29_board_init(void)
+{
+       rk29_board_iomux_init();
+
+       gpio_request(POWER_ON_PIN,"poweronpin");
+       gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
+       gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
+       gpio_request(RK29_PIN0_PA0,NULL);
+       gpio_direction_output(RK29_PIN0_PA0, 0);
+
+       pm_power_off = rk29_pm_power_off;
+       //arm_pm_restart = rk29_pm_power_restart;
+
+       board_update_cpufreq_table(freq_table);
+
+       platform_add_devices(devices, ARRAY_SIZE(devices));
+#ifdef CONFIG_I2C0_RK29
+       i2c_register_board_info(default_i2c0_data.bus_num, board_i2c0_devices,
+                       ARRAY_SIZE(board_i2c0_devices));
+#endif
+#ifdef CONFIG_I2C1_RK29
+       i2c_register_board_info(default_i2c1_data.bus_num, board_i2c1_devices,
+                       ARRAY_SIZE(board_i2c1_devices));
+#endif
+#ifdef CONFIG_I2C2_RK29
+       i2c_register_board_info(default_i2c2_data.bus_num, board_i2c2_devices,
+                       ARRAY_SIZE(board_i2c2_devices));
+#endif
+#ifdef CONFIG_I2C3_RK29
+       i2c_register_board_info(default_i2c3_data.bus_num, board_i2c3_devices,
+                       ARRAY_SIZE(board_i2c3_devices));
+#endif
+
+       spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+       rk29sdk_wifi_bt_gpio_control_init();
+       rk29sdk_init_wifi_mem();
+#endif
+
+ #if (defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) && defined(CONFIG_TOUCHSCREEN_480X800)) \
+       || defined(CONFIG_TOUCHSCREEN_HX8520_IIC) || defined(CONFIG_TOUCHSCREEN_GT801_IIC)\
+       || defined(CONFIG_TOUCHSCREEN_PIXCIR) || defined(CONFIG_TOUCHSCREEN_FT5X0X)\
+       || defined(CONFIG_TOUCHSCREEN_ILI2102_IIC)
+       rk29xx_virtual_keys_init();
+ #endif
+
+}
+
+static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
+                                       char **cmdline, struct meminfo *mi)
+{
+       mi->nr_banks = 1;
+       mi->bank[0].start = RK29_SDRAM_PHYS;
+       //mi->bank[0].node = PHYS_TO_NID(RK29_SDRAM_PHYS);
+       mi->bank[0].size = LINUX_SIZE;
+#if SDRAM_SIZE > SZ_512M
+       mi->nr_banks = 2;
+       mi->bank[1].start = RK29_SDRAM_PHYS + SZ_512M;
+       mi->bank[1].size = SDRAM_SIZE - SZ_512M;
+#endif
+}
+
+static void __init machine_rk29_mapio(void)
+{
+       rk29_map_common_io();
+       rk29_setup_early_printk();
+       rk29_sram_init();
+       rk29_clock_init2(periph_pll_96mhz, codec_pll_300mhz, false);
+       rk29_iomux_init();
+       ddr_init(DDR_TYPE, DDR_FREQ);
+}
+
+MACHINE_START(RK29, "RK29board")
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37))
+       /* UART for LL DEBUG */
+       .phys_io        = RK29_UART1_PHYS & 0xfff00000,
+       .io_pg_offst    = ((RK29_UART1_BASE) >> 18) & 0xfffc,
+#endif
+       .boot_params    = RK29_SDRAM_PHYS + 0x88000,
+       .fixup          = machine_rk29_fixup,
+       .map_io         = machine_rk29_mapio,
+       .init_irq       = machine_rk29_init_irq,
+       .init_machine   = machine_rk29_board_init,
+       .timer          = &rk29_timer,
+MACHINE_END
index 181c02e4cad1f21842e7d411aa56b874b9717d98..308897e4c3061af124d3ded6bc2ff15fe4506f39 100755 (executable)
@@ -7,6 +7,11 @@
  * Author: 
  * hcy@rock-chips.com
  * yk@rock-chips.com
+ * 
+ * v2.02 
+ * reset DRAM DLL at update_mr
+ * adjust ZQCR0, MR0,MR1,MR2 for ODT and driver strengh
+ *
  * v2.01 
  * disable DFTCMP
  */
 #define DDR3_MR1_RTT_NOM(n) (((n&1)<<2)|((n&2)<<5)|((n&4)<<7))
 
 //mr2 for ddr3
+#define DDR3_MR2_RTT_WR(n) ((n&0x3)<<9)
 #define DDR3_MR2_CWL(n) (((n-5)&0x7)<<3)
 
 //EMR;                    //Extended Mode Register      
@@ -532,7 +538,6 @@ static __sramdata uint32_t tWR_MR0;
 static __sramdata uint32_t cl;
 static __sramdata uint32_t cwl;
 
-static __sramdata uint32_t cpu_freq;
 static __sramdata uint32_t ddr_freq;
 static __sramdata volatile uint32_t ddr_stop;
 
@@ -543,17 +548,17 @@ Cpu highest frequency is 1.2 GHz
 1 cycle = 1/1.2 ns
 1 us = 1000 ns = 1000 * 1.2 cycles = 1200 cycles
 *****************************************************************************/
-//static 
-void __sramlocalfunc delayus(uint32_t us)
+static __sramdata uint32_t loops_per_us;
+
+#define LPJ_100MHZ     499728UL
+
+/*static*/ void __sramlocalfunc delayus(uint32_t us)
 {      
-     uint32_t count;
-     if(cpu_freq == 24)
-         count = us * 6;//533;
-     else
-        count = us*200;
-     while(count--)  // 3 cycles
+    uint32_t count;
+     
+    count = loops_per_us*us;
+    while(count--)  // 3 cycles
                barrier();
-
 }
 
 static uint32_t __sramlocalfunc ddr_get_parameter(uint32_t nMHz)
@@ -926,7 +931,7 @@ static uint32_t __sramlocalfunc ddr_update_timing(void)
         pDDR_Reg->TPR[1] = value | TFAW(tFAW);
         // ddr3 tCKE should be tCKESR=tCKE+1nCK
         pDDR_Reg->TPR[2] = TXS(tXS) | TXP(tXP) | TCKE(4);//0x198c8;//       
-        
+        pDDR_Reg->ZQCR[0] = 0x10039d29;//(pDDR_Reg->ZQSR & (0x3FF)) | (0x6<<10) | (0x6<<15) | (0x1<<28);
     }
     else if(mem_type == DDRII)
     {
@@ -965,9 +970,20 @@ static uint32_t __sramlocalfunc ddr_update_mr(void)
     if(mem_type == DDR3)
     {
         pDDR_Reg->TPR3 = value | CL(cl) | CWL(cwl) | WR(tWR);
-        pDDR_Reg->MR = DDR3_BL8 | DDR3_CL(cl) | DDR3_MR0_WR(tWR_MR0)/*15 ns*/;
+        pDDR_Reg->MR = DDR3_BL8 | DDR3_CL(cl) | DDR3_MR0_DLL_RESET | DDR3_MR0_WR(tWR_MR0)/*15 ns*/;
         delayus(1);
-        pDDR_Reg->EMR2 = DDR3_MR2_CWL(cwl);
+        /*
+         * DIC:Output Driver Impedance Control,0, RZQ(240)/6
+         * Rtt_Nom:2 RZQ(240)/2
+         */
+        pDDR_Reg->EMR = DDR3_MR1_DIC(0) | DDR3_MR1_AL(0) | DDR3_MR1_RTT_NOM(2);
+        delayus(1);
+        /* DDR3 :CWL=5
+         * RTT_WR: 1, RZQ(240)/4
+         */
+        pDDR_Reg->EMR2 = DDR3_MR2_RTT_WR(1)|DDR3_MR2_CWL(cwl);
+        delayus(1);
+        pDDR_Reg->EMR3 = 0x0;
     }
     else if(mem_type == DDRII)
     {
@@ -1047,7 +1063,7 @@ static uint32_t __sramlocalfunc ddr_set_pll(uint32_t nMHz, uint32_t set)
 
         delayus(1);  //delay at least 500ns
         pSCU_Reg->CRU_DPLL_CON &= ~(0x1<<15);
-        delayus(2000); // 7.2us*140=1.008ms
+        delayus(500); // wait for DPLL stable
 
         // ddr pll normal
         pSCU_Reg->CRU_MODE_CON |= 0x1<<6;
@@ -1087,7 +1103,7 @@ void __sramlocalfunc ddr_selfrefresh_enter(void)
     pSCU_Reg->CRU_SOFTRST_CON[0] |= (0x1F<<19);  //reset DLL
     delayus(1);
     pSCU_Reg->CRU_CLKGATE_CON[0] |= (0x1<<18);  //close DDR PHY clock
-    delayus(10);
+    delayus(1);
         pDDR_Reg->DLLCR09[0] =0x80000000;
         pDDR_Reg->DLLCR09[9] =0x80000000;
         pDDR_Reg->DLLCR09[1] =0x80000000;
@@ -1105,13 +1121,13 @@ void __sramlocalfunc ddr_selfrefresh_exit(void)
        6. Re-enables all host ports
      */
     pSCU_Reg->CRU_CLKGATE_CON[0] &= ~(0x1<<18);  //open DDR PHY clock
-    delayus(10); 
+    delayus(1); 
     pSCU_Reg->CRU_SOFTRST_CON[0] &= ~(0x1F<<19); //de-reset DLL
-    delayus(1000); 
+    delayus(10); 
     pDDR_Reg->CCR &= ~ITMRST;   //ITM reset
-    delayus(500); 
+    delayus(5); 
     pDDR_Reg->DCR = (pDDR_Reg->DCR & (~((0x1<<24) | (0x1<<13) | (0xF<<27) | (0x1<<31)))) | ((0x1<<13) | (0x7<<27) | (0x1<<31)); //exit    
-    delayus(1000);
+    delayus(10);
     ddr_update_mr();
     delayus(1);
 
@@ -1120,8 +1136,8 @@ refresh:
     pDDR_Reg->DRR |= RD;
     delayus(1);
     pDDR_Reg->CCR |= DTT;
-    //delayus(15);
     dsb();
+    delayus(10);
     do
     {
         delayus(1);
@@ -1148,16 +1164,22 @@ uint32_t __sramfunc ddr_change_freq(uint32_t nMHz)
        volatile u32 n; 
     unsigned long flags;
     volatile unsigned int * temp=(volatile unsigned int *)SRAM_CODE_OFFSET;
-
-    if((pSCU_Reg->CRU_MODE_CON & 0x03) == 0x03)
-        cpu_freq = 24;
-    else 
-        cpu_freq = clk_get_rate(clk_get(NULL,"core"))/1000000;
+     uint32_t regvalue = pSCU_Reg->CRU_APLL_CON;
+     uint32_t freq;
+
+     // freq = (Fin/NR)*NF/OD
+     if((pSCU_Reg->CRU_MODE_CON&3) == 1)             // CPLL Normal mode
+         freq = 24 *((((regvalue>>3)&0x7f)+1)<<1)    // NF = 2*(CLKF+1)
+                /(((regvalue>>10)&0x1f)+1)           // NR = CLKR+1
+                *(2<<((regvalue>>1)&3));             // OD = 2^CLKOD
+     else
+        freq = 24;
+        
+    loops_per_us = LPJ_100MHZ*freq / 1000000;
     
     ret = ddr_set_pll(nMHz, 0);
     ddr_get_parameter(ret);
     /** 1. Make sure there is no host access */
-#if 1
     local_irq_save(flags);
     flush_cache_all();
     __cpuc_flush_kern_all();
@@ -1175,7 +1197,6 @@ uint32_t __sramfunc ddr_change_freq(uint32_t nMHz)
     n= pDDR_Reg->CCR;
     n= pSCU_Reg->CRU_SOFTRST_CON[0];
     dsb();
-#endif
     
     /** 2. ddr enter self-refresh mode or precharge power-down mode */
     ddr_selfrefresh_enter();
@@ -1237,9 +1258,19 @@ void __sramfunc ddr_suspend(void)
 {
     uint32_t n;
     volatile unsigned int * temp=(volatile unsigned int *)SRAM_CODE_OFFSET;
+    uint32_t regvalue = pSCU_Reg->CRU_APLL_CON;
+    uint32_t freq;
+    
+    // freq = (Fin/NR)*NF/OD
+    if((pSCU_Reg->CRU_MODE_CON&3) == 1)             // CPLL Normal mode
+        freq = 24 *((((regvalue>>3)&0x7f)+1)<<1)    // NF = 2*(CLKF+1)
+               /(((regvalue>>10)&0x1f)+1)           // NR = CLKR+1
+               *(2<<((regvalue>>1)&3));             // OD = 2^CLKOD
+    else
+       freq = 24;
+       
+    loops_per_us = LPJ_100MHZ*freq / 1000000;
 
-    cpu_freq = 24;
-       
     /** 1. Make sure there is no host access */
     flush_cache_all();
     __cpuc_flush_kern_all();
@@ -1321,10 +1352,12 @@ void __sramfunc ddr_resume(void)
     delayus(1);
     #endif
     
-#if 1
-     pSCU_Reg->CRU_DPLL_CON &= ~(0x1 << 15);  //power on DPLL   
-    //   while(!(pGRF_Reg->GRF_SOC_CON[0] & (1<<28)));
-     delayus(500); // 7.2us*140=1.008ms // Ëø¶¨pll
+    pSCU_Reg->CRU_DPLL_CON &= ~(0x1 << 15);  //power on DPLL   
+    delayus(300); //     Ëø¶¨pll
+    do
+    {
+        delayus(3);
+    }while(!(pGRF_Reg->GRF_SOC_CON[0] & (1<<28)));  //wait pll lock
     // ddr pll normal
     value = pSCU_Reg->CRU_MODE_CON;
     value &=~(0x3<<6);
@@ -1338,7 +1371,6 @@ void __sramfunc ddr_resume(void)
     pSCU_Reg->CRU_CLKGATE_CON[1] &= ~(0x1<<6);      //close DDR PERIPH AXI clock
     pSCU_Reg->CRU_CLKGATE_CON[0] &= ~(0x1<<18);     //enable DDR PHY clock
     delayus(1);   
-#endif
 
     ddr_selfrefresh_exit();
        dsb(); 
@@ -1372,7 +1404,6 @@ typedef struct _dtt_cnt_t
     uint32_t  cnt;
 }dtt_cnt_t;
 
-//static int __init ddr_probe(void)
 int ddr_init(uint32_t dram_type, uint32_t freq)
 {
     volatile uint32_t value = 0;
@@ -1383,7 +1414,7 @@ int ddr_init(uint32_t dram_type, uint32_t freq)
     uint32_t          bank = 0;
     uint32_t          n;
 
-    ddr_print("version 2.01 20110504 \n");
+    ddr_print("version 2.02 20111109 \n");
 
     mem_type = (pDDR_Reg->DCR & 0x3);
     ddr_type = dram_type;//DDR3_TYPE;//
@@ -1450,6 +1481,8 @@ int ddr_init(uint32_t dram_type, uint32_t freq)
     }
     pDDR_Reg->DTAR = value;
     pDDR_Reg->CCR  &= ~(DFTCMP);
+    pDDR_Reg->IOCR = AUTO_CMD_IOPD(3) | AUTO_DATA_IOPD(3) | DQ_ODT | DQS_ODT |  DQRTT | DQSRTT;
+    
     //pDDR_Reg->CCR |= DQSCFG;// passive windowing mode
 
     if((mem_type == DDRII) || (mem_type == DDR3))
@@ -1492,8 +1525,6 @@ int ddr_init(uint32_t dram_type, uint32_t freq)
 }
 EXPORT_SYMBOL(ddr_init);
 
-//core_initcall_sync(ddr_probe);
-
 #ifdef CONFIG_DDR_RECONFIG
 #include "ddr_reconfig.c"
 #endif
index 0f49e6c8cb383de9a34aabac313e13c3d8e3534e..264a6373681688677ea3aeae073092f064dd74aa 100644 (file)
@@ -221,6 +221,16 @@ struct platform_device rk29_device_backlight = {
         }
 };
 #endif
+
+#ifdef CONFIG_BUTTON_LIGHT
+struct platform_device rk29_device_buttonlight = {
+               .name = "rk29_button_light",
+               .id = -1,
+               .dev = {
+                       .platform_data = &rk29_button_light_info,
+               }
+};
+#endif
 #ifdef CONFIG_SDMMC0_RK29 
 #ifndef CONFIG_EMMC_RK29 
 static struct resource resources_sdmmc0[] = {
index b6d2d16d5927d09622b5d3a958f428615f46d7ab..1a3eefa72ebb6cabc80e7626c9333cf7b50a5cff 100644 (file)
@@ -65,7 +65,9 @@ extern struct platform_device rk29_device_sdmmc1;
 extern struct platform_device rk29_device_adc;
 extern struct platform_device rk29_device_vmac;
 extern struct rk29_bl_info    rk29_bl_info;
+extern struct rk29_button_light_info rk29_button_light_info;
 extern struct platform_device rk29_device_backlight;
+extern struct platform_device rk29_device_buttonlight;
 extern struct platform_device rk29_device_usb20_otg;
 extern struct platform_device rk29_device_usb20_host;
 extern struct platform_device rk29_device_usb11_host;
index 3fdad366bcd7d134367bda7f3e857a64e79bce01..d9c9068afcafa0565e77643a84de8e669cc4f91c 100755 (executable)
@@ -248,6 +248,17 @@ struct mma8452_platform_data {
     int     (*mma8452_platform_wakeup)(void);
     void    (*exit_platform_hw)(void);
 };
+struct bma023_platform_data {
+    u16     model;
+       u16     swap_xy;
+       u16             swap_xyz;
+       signed char orientation[9];
+    int     (*get_pendown_state)(void);
+    int     (*init_platform_hw)(void);
+    int     (*mma8452_platform_sleep)(void);
+    int     (*mma8452_platform_wakeup)(void);
+    void    (*exit_platform_hw)(void);
+};
 
 struct cm3202_platform_data {
        int CM3202_SD_IOPIN;
index a9314741a701a20fa654db14abc2bfab340b76c5..9511c7daa848735a8e95f4e25db838af5e368c14 100755 (executable)
@@ -157,28 +157,21 @@ void __sramfunc ddr_testmode(void)
     {
         for (;;)
         {
-               sram_printch(' ');
-               sram_printch('8');
-               sram_printch('8');
-               sram_printch('8');
-               sram_printch(' ');
+               sram_printascii("change freq\n");
             g_crc1 = calc_crc32((u32)_stext, (size_t)(_etext-_stext));
-            nMHz = 333 + (random32()>>25);
-            if(nMHz > 402)
-                nMHz = 402;
+            nMHz = 333 + random32();
+            nMHz %= 490;
+            if(nMHz < 100)
+                nMHz = 100;
+            nMHz = ddr_change_freq(nMHz);
                printhex(nMHz);
                sram_printch(' ');
                printhex(n++);
-            //ddr_print("%s change freq to: %d MHz\n", __func__, nMHz);
-            ddr_change_freq(nMHz);
+               sram_printch(' ');
             g_crc2 = calc_crc32((u32)_stext, (size_t)(_etext-_stext));
             if (g_crc1!=g_crc2)
             {
-                   sram_printch(' ');
-                   sram_printch('f');
-                   sram_printch('a');
-                   sram_printch('i');
-                   sram_printch('l');
+                   sram_printascii("fail\n");
                }
                //ddr_print("check image crc32 success--crc value = 0x%x!, count:%d\n",g_crc1, n++);
            //     sram_printascii("change freq success\n");
@@ -253,7 +246,7 @@ static void __sramfunc rk29_sram_suspend(void)
 {
        u32 vol;
 
-       if ((ddr_debug == 1) || (ddr_debug == 2))
+       if (ddr_debug == 2)
                ddr_testmode();
 
        sram_printch('5');
@@ -418,7 +411,7 @@ static int rk29_pm_enter(suspend_state_t state)
        #endif
        
        // memory teseter
-       if (ddr_debug == 3)
+       if (ddr_debug != 2)
                ddr_testmode();
 
        // dump GPIO INTEN for debug
index 7e49d6ee3e0ab2a428dd7ffae4b32211adbba56c..56760c7d84847de8341f1200da116ec337327d36 100755 (executable)
@@ -7,7 +7,21 @@
 #include <asm/io.h>
 #include <mach/gpio.h>
 
+#include <asm/vfp.h>
 
+#if 1
+void __sramfunc sram_printch(char byte);
+void __sramfunc printhex(unsigned int hex);
+#define sram_printHX(a)
+#else
+#define sram_printch(a)
+#define sram_printHX(a)
+#endif
+
+#define grf_readl(offset) readl(RK29_GRF_BASE + offset)
+#define grf_writel(v, offset) do { writel(v, RK29_GRF_BASE + offset); readl(RK29_GRF_BASE + offset); } while (0)
+
+#define sram_udelay(usecs,a) LOOP((usecs)*LOOPS_PER_USEC)
 
 #if defined(CONFIG_RK29_SPI_INSRAM)
 
@@ -17,7 +31,7 @@
 #define SPI_SR_SPEED (2*SPI_MHZ)
 
 
-#if defined(CONFIG_MACH_RK29_A22)||defined(CONFIG_MACH_RK29_PHONESDK)
+#if defined(CONFIG_MACH_RK29_A22)||defined(CONFIG_MACH_RK29_PHONESDK)||defined(CONFIG_MACH_RK29_TD8801_V2)
 
 #define SRAM_SPI_CH 1
 #define SRAM_SPI_CS 1
@@ -85,15 +99,6 @@ SPI_BAUDR,
 SPI_SER,
 DATE_END,
 };
-#if 1
-void __sramfunc sram_printch(char byte);
-void __sramfunc printhex(unsigned int hex);
-#define sram_printHX(a)
-#else
-#define sram_printch(a)
-#define sram_printHX(a)
-#endif
-
  static u32 __sramdata spi_data[DATE_END]={};
 
 #define sram_spi_dis()  spi_writel(spi_readl(SPIM_ENR)&~(0x1<<0),SPIM_ENR)
@@ -105,10 +110,6 @@ void __sramfunc printhex(unsigned int hex);
 #define spi_readl(offset) readl(SRAM_SPI_ADDRBASE + offset)
 #define spi_writel(v, offset) writel(v, SRAM_SPI_ADDRBASE+ offset)
 
-#define grf_readl(offset) readl(RK29_GRF_BASE + offset)
-#define grf_writel(v, offset) do { writel(v, RK29_GRF_BASE + offset); readl(RK29_GRF_BASE + offset); } while (0)
-
-#define sram_udelay(usecs,a) LOOP((usecs)*LOOPS_PER_USEC)
 
 #define SPI_GATE1_MASK 0xCF
 
@@ -362,6 +363,10 @@ void __sramfunc rk29_suspend_voltage_resume(unsigned int vol)
 #endif
 /*******************************************gpio*********************************************/
 #ifdef CONFIG_RK29_CLK_SWITCH_TO_32K
+#define PM_GETGPIO_BASE(N) RK29_GPIO##N##_BASE
+#define PM_GPIO_DR 0
+#define PM_GPIO_DDR 0x4
+#define PM_GPIO_INTEN 0x30
 __sramdata u32  pm_gpio_base[7]=
 {
 RK29_GPIO0_BASE,
@@ -410,10 +415,240 @@ void __sramfunc pm_gpio_set(unsigned gpio,eGPIOPinDirection_t direction,eGPIOPin
        }
 }
 #endif
+/*****************************************gpio ctr*********************************************/
+#if defined(CONFIG_RK29_GPIO_SUSPEND)
+#define GRF_GPIO0_DIR     0x000
+#define GRF_GPIO1_DIR     0x004
+#define GRF_GPIO2_DIR     0x008
+#define GRF_GPIO3_DIR     0x00c
+#define GRF_GPIO4_DIR     0x010
+#define GRF_GPIO5_DIR     0x014
+
+
+#define GRF_GPIO0_DO      0x018
+#define GRF_GPIO1_DO      0x01c
+#define GRF_GPIO2_DO      0x020
+#define GRF_GPIO3_DO      0x024
+#define GRF_GPIO4_DO      0x028
+#define GRF_GPIO5_DO      0x02c
+
+#define GRF_GPIO0_EN      0x030
+#define GRF_GPIO1_EN      0x034
+#define GRF_GPIO2_EN      0x038
+#define GRF_GPIO3_EN      0x03c
+#define GRF_GPIO4_EN      0x040
+#define GRF_GPIO5_EN      0x044
+
+
+#define GRF_GPIO0L_IOMUX  0x048
+#define GRF_GPIO0H_IOMUX  0x04c
+#define GRF_GPIO1L_IOMUX  0x050
+#define GRF_GPIO1H_IOMUX  0x054
+#define GRF_GPIO2L_IOMUX  0x058
+#define GRF_GPIO2H_IOMUX  0x05c
+#define GRF_GPIO3L_IOMUX  0x060
+#define GRF_GPIO3H_IOMUX  0x064
+#define GRF_GPIO4L_IOMUX  0x068
+#define GRF_GPIO4H_IOMUX  0x06c
+#define GRF_GPIO5L_IOMUX  0x070
+#define GRF_GPIO5H_IOMUX  0x074
+
+typedef struct GPIO_IOMUX
+{
+    unsigned int GPIOL_IOMUX;
+    unsigned int GPIOH_IOMUX;
+}GPIO_IOMUX_PM;
+
+//GRF Registers
+typedef  struct REG_FILE_GRF
+{
+   unsigned int GRF_GPIO_DIR[6];
+   unsigned int GRF_GPIO_DO[6];
+   unsigned int GRF_GPIO_EN[6];
+   GPIO_IOMUX_PM GRF_GPIO_IOMUX[6];
+   unsigned int GRF_GPIO_PULL[7];
+} GRF_REG_SAVE;
+
+
+static GRF_REG_SAVE  pm_grf;
+int __sramdata crumode;
+ u32 __sramdata gpio2_pull,gpio6_pull;
+//static GRF_REG_SAVE __sramdata pm_grf;
+static void  pm_keygpio_prepare(void)
+{
+       gpio6_pull = grf_readl(GRF_GPIO6_PULL);
+       gpio2_pull = grf_readl(GRF_GPIO2_PULL);
+}
+ void  pm_keygpio_sdk_suspend(void)
+{
+    pm_keygpio_prepare();
+       grf_writel(gpio6_pull|0x7f,GRF_GPIO6_PULL);//key pullup/pulldown disable
+       grf_writel(gpio2_pull|0x00000f30,GRF_GPIO2_PULL);
+}
+ void  pm_keygpio_sdk_resume(void)
+{
+       grf_writel(gpio6_pull,GRF_GPIO6_PULL);//key pullup/pulldown enable
+       grf_writel(gpio2_pull,GRF_GPIO2_PULL);
+}
+ void  pm_keygpio_a22_suspend(void)
+{
+    pm_keygpio_prepare();
+       grf_writel(gpio6_pull|0x7f,GRF_GPIO6_PULL);//key pullup/pulldown disable
+       grf_writel(gpio2_pull|0x00000900,GRF_GPIO2_PULL);
+}
+ void  pm_keygpio_a22_resume(void)
+{
+       grf_writel(gpio6_pull,GRF_GPIO6_PULL);//key pullup/pulldown enable
+       grf_writel(gpio2_pull,GRF_GPIO2_PULL);
+}
+
+
+static void  pm_spi_gpio_prepare(void)
+{
+       pm_grf.GRF_GPIO_IOMUX[1].GPIOL_IOMUX = grf_readl(GRF_GPIO1L_IOMUX);
+       pm_grf.GRF_GPIO_IOMUX[2].GPIOH_IOMUX = grf_readl(GRF_GPIO2H_IOMUX);
+
+       pm_grf.GRF_GPIO_PULL[1] = grf_readl(GRF_GPIO1_PULL);
+       pm_grf.GRF_GPIO_PULL[2] = grf_readl(GRF_GPIO2_PULL);
+
+       pm_grf.GRF_GPIO_EN[1] = grf_readl(GRF_GPIO1_EN);
+       pm_grf.GRF_GPIO_EN[2] = grf_readl(GRF_GPIO2_EN);
+}
+
+ void  pm_spi_gpio_suspend(void)
+{
+       int io1L_iomux;
+       int io2H_iomux;
+       int io1_pull,io2_pull;
+       int io1_en,io2_en;
+
+       pm_spi_gpio_prepare();
+
+       io1L_iomux = grf_readl(GRF_GPIO1L_IOMUX);
+       io2H_iomux = grf_readl(GRF_GPIO2H_IOMUX);
+
+       grf_writel(io1L_iomux&(~((0x03<<6)|(0x03 <<8))), GRF_GPIO1L_IOMUX);
+       grf_writel(io2H_iomux&0xffff0000, GRF_GPIO2H_IOMUX);
+
+       io1_pull = grf_readl(GRF_GPIO1_PULL);
+       io2_pull = grf_readl(GRF_GPIO2_PULL);
+
+       grf_writel(io1_pull|0x18,GRF_GPIO1_PULL);
+       grf_writel(io2_pull|0x00ff0000,GRF_GPIO2_PULL);
+
+       io1_en = grf_readl(GRF_GPIO1_EN);
+       io2_en = grf_readl(GRF_GPIO2_EN);
+
+       grf_writel(io1_en|0x18,GRF_GPIO1_EN);
+       grf_writel(io2_en|0x00ff0000,GRF_GPIO2_EN);
+}
+
+ void  pm_spi_gpio_resume(void)
+{
+       grf_writel(pm_grf.GRF_GPIO_EN[1],GRF_GPIO1_EN);
+       grf_writel(pm_grf.GRF_GPIO_EN[2],GRF_GPIO2_EN);
+       grf_writel(pm_grf.GRF_GPIO_PULL[1],GRF_GPIO1_PULL);
+       grf_writel(pm_grf.GRF_GPIO_PULL[2],GRF_GPIO2_PULL);
+
+       grf_writel(pm_grf.GRF_GPIO_IOMUX[1].GPIOL_IOMUX, GRF_GPIO1L_IOMUX);
+       grf_writel(pm_grf.GRF_GPIO_IOMUX[2].GPIOH_IOMUX, GRF_GPIO2H_IOMUX);
+}
+
+void pm_gpio_suspend(void)
+{
+       pm_spi_gpio_suspend(); // spi  pullup/pulldown  disable....
+       #if defined(CONFIG_MACH_RK29_PHONESDK)
+       {       pm_keygpio_sdk_suspend();// key  pullup/pulldown  disable.....
+       }
+       #endif
+       #if defined(CONFIG_MACH_RK29_A22)
+       {       pm_keygpio_a22_suspend();// key  pullup/pulldown  disable.....
+       }
+       #endif
+}
+void pm_gpio_resume(void)
+{
+       pm_spi_gpio_resume(); // spi  pullup/pulldown  enable.....
+       #if defined(CONFIG_MACH_RK29_PHONESDK)
+       {       pm_keygpio_sdk_resume();// key  pullup/pulldown  enable.....
+       }
+       #endif
+       #if defined(CONFIG_MACH_RK29_A22)
+       {       pm_keygpio_a22_resume();// key  pullup/pulldown  enable.....
+       }
+       #endif
+}
+#else
+void pm_gpio_suspend(void)
+{}
+void pm_gpio_resume(void)
+{}
+#endif
+/*************************************neon powerdomain******************************/
+#define vfpreg(_vfp_) #_vfp_
+
+#define fmrx(_vfp_) ({                 \
+       u32 __v;                        \
+       asm("mrc p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmrx   %0, " #_vfp_    \
+           : "=r" (__v) : : "cc");     \
+       __v;                            \
+ })
+
+#define fmxr(_vfp_,_var_)              \
+       asm("mcr p10, 7, %0, " vfpreg(_vfp_) ", cr0, 0 @ fmxr   " #_vfp_ ", %0" \
+          : : "r" (_var_) : "cc")
+
+#define pmu_read(offset)               readl(RK29_PMU_BASE + (offset))
+#define pmu_write(offset, value)       writel((value), RK29_PMU_BASE + (offset))
+#define PMU_PG_CON 0x10
+extern void vfp_save_state(void *location, u32 fpexc);
+extern void vfp_load_state(void *location, u32 fpexc);
+ static u64 __sramdata saveptr[33]={};
+void  neon_powerdomain_off(void)
+{
+       int ret,i=0;
+       int *p;
+       p=&saveptr;
+        unsigned int fpexc = fmrx(FPEXC);  //get neon Logic gate
+
+       fmxr(FPEXC, fpexc | FPEXC_EN);  //open neon Logic gate
+       for(i=0;i<34;i++){
+       vfp_save_state(p,fpexc);                        //save neon reg,32 D reg,2 control reg
+       p++;
+       }
+       fmxr(FPEXC, fpexc & ~FPEXC_EN);    //close neon Logic gate
+
+        ret=pmu_read(PMU_PG_CON);                   //get power domain state
+       pmu_write(PMU_PG_CON,ret|(0x1<<1));          //powerdomain off neon
+
+}
+void   neon_powerdomain_on(void)
+{
+       int ret,i=0;
+       int *p;
+       p=&saveptr;
+
+       ret=pmu_read(PMU_PG_CON);                   //get power domain state
+       pmu_write(PMU_PG_CON,ret&~(0x1<<1));                //powerdomain on neon
+       sram_udelay(5000,24);
+
+       unsigned int fpexc = fmrx(FPEXC);              //get neon Logic gate
+       fmxr(FPEXC, fpexc | FPEXC_EN);                   //open neon Logic gate
+       for(i=0;i<34;i++){
+       vfp_load_state(p,fpexc);   //recovery neon reg, 32 D reg,2 control reg
+       p++;
+       }
+       fmxr(FPEXC, fpexc | FPEXC_EN);      //open neon Logic gate
+
+}
+
+
+
+
 /*************************************************32k**************************************/
 
 #ifdef CONFIG_RK29_CLK_SWITCH_TO_32K
-static int __sramdata crumode;
+//static int __sramdata crumode;
 void __sramfunc pm_clk_switch_32k(void)
 {
        int vol;
index 3294f55ff520028442043780aaf331960c6034ba..d6e9e5a48fd8a70de781fc2c1d367164f08f15c5 100755 (executable)
@@ -6,7 +6,6 @@
 #include <linux/poll.h>\r
 #include <linux/fs.h>\r
 #include <linux/list.h>\r
-#include <linux/smp_lock.h>\r
 \r
 #define CMMB_MAJOR 200\r
 \r
@@ -54,4 +53,4 @@ void cmmb_unregister_device(struct cmmb_device *cmmbdev);
        FUNCTION(ARGS); \\r
 \r
 \r
-#endif/* #ifndef _CMMB_CLASS_H_ */
\ No newline at end of file
+#endif/* #ifndef _CMMB_CLASS_H_ */\r
index ca8c2005aa89d8dd574d992672166845a4706792..0e8c03d267988e6d346fd88448823ec7f42d6b87 100755 (executable)
@@ -4,6 +4,8 @@
 #include <linux/workqueue.h>\r
 #include <asm/atomic.h>\r
 #include <linux/vmalloc.h> \r
+#include <linux/slab.h>
+
 #if 1\r
 #define DBGERR(x...)   printk(KERN_INFO x)\r
 #else\r
index 52d8bc2788969e1e4f7ad9d3980a1724ec3cbf80..79a09e98283d8a570196183bdf00ff9486e0a81e 100755 (executable)
@@ -37,6 +37,7 @@
 #include "smsendian.h"
 #include "sms-cards.h"
 #include <mach/gpio.h>
+#include <linux/slab.h>
 
 #define MAX_GPIO_PIN_NUMBER    31
 
index 392a6ed64f0a60584421b690f6963022241cd517..086292ce7abfec7a844a61b0111197285255b27c 100755 (executable)
@@ -42,5 +42,8 @@ int  smsspibus_ssp_resume(void* context);
        unsigned int cmmb_pw_rst;
        unsigned int cmmb_irq;
        void (*io_init_mux)(void);
+       void (*cmmb_io_pm)(void);
+       void (*cmmb_power_on)(void);
+       void (*cmmb_power_down)(void);
 };
 #endif /* __SMS_SPI_PHY_H__ */
index 9ea5f095fc56a9ef958aecac72b213b8dbd6b56a..e5b6f6d178ac56f1cef184d9590ad93894e9fe63 100755 (executable)
 #define enable 1
 #define disable 0
 
-extern int wm8994_set_status(void);
 
+/*#ifdef CONFIG_SND_SOC_WM8994
+extern int wm8994_set_status(void);
+#endif
+*/
 /* headset private data */
 struct headset_priv {
        struct input_dev *input_dev;
@@ -259,13 +262,13 @@ static void Hook_work(struct work_struct *work)
                DBG("Headset is out\n");
                goto RE_ERROR;
        }       
-       #ifdef CONFIG_SND_SOC_WM8994
+       /*#ifdef CONFIG_SND_SOC_WM8994
        if(wm8994_set_status() < 0)
        {
                DBG("wm8994 is not set on heatset channel or suspend\n");
                goto RE_ERROR;
        }
-       #endif          
+       #endif*/
        for(i=0; i<3; i++)
        {
                level = gpio_get_value(pdata->Hook_gpio);
@@ -326,7 +329,7 @@ static void headset_timer_callback(unsigned long arg)
                DBG("Headset is out\n");
                goto out;
        }
-       #ifdef CONFIG_SND_SOC_WM8994
+       /*#ifdef CONFIG_SND_SOC_WM8994
        if(wm8994_set_status() < 0)
        {
                DBG("wm8994 is not set on heatset channel\n");
@@ -334,7 +337,7 @@ static void headset_timer_callback(unsigned long arg)
                add_timer(&headset_info->headset_timer);        
                goto out;
        }
-       #endif
+       #endif*/
        for(i=0; i<3; i++)
        {
                level = gpio_get_value(pdata->Hook_gpio);
index efb19a016b3853423028e87da354c4e2be3ab569..30cda547ea2f6e3217a93d4d53327aaad90ae20c 100755 (executable)
@@ -53,4 +53,11 @@ config GS_L3G4200D
          To have support for your specific gsesnor you will have to
          select the proper drivers which depend on this option.
 
+config GS_BMA023
+  bool "gs_bma023"
+  depends on G_SENSOR_DEVICE
+  default n
+  help
+    To have support for your specific gsesnor you will have to
+    select the proper drivers which depend on this option.
 endif
index 2f7f9c0ad14cb93f41457decfed2c253d8cdd1dc..f1bdebf8c1f8ae2925533b9ed640a25ef9822aab 100755 (executable)
@@ -4,4 +4,5 @@ obj-$(CONFIG_GS_MMA7660)        += mma7660.o
 obj-$(CONFIG_GS_MMA8452)       += mma8452.o
 obj-$(CONFIG_GS_L3G4200D)      += l3g4200d.o
 obj-$(CONFIG_GS_KXTF9)         += kxtf9.o
-obj-$(CONFIG_GS_LIS3DH)                += lis3dh_acc_misc.o
\ No newline at end of file
+obj-$(CONFIG_GS_LIS3DH)                += lis3dh_acc_misc.o
+obj-$(CONFIG_GS_BMA023)        += bma023.o
diff --git a/drivers/input/gsensor/bma023.c b/drivers/input/gsensor/bma023.c
new file mode 100644 (file)
index 0000000..d4d66cb
--- /dev/null
@@ -0,0 +1,920 @@
+/* drivers/i2c/chips/bma023.c - bma023 compass driver
+ *
+ * Copyright (C) 2007-2008 HTC Corporation.
+ * Author: Hou-Kun Chen <houkun.chen@gmail.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/irq.h>
+#include <linux/miscdevice.h>
+#include <linux/gpio.h>
+#include <asm/uaccess.h>
+#include <asm/atomic.h>
+#include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/freezer.h>
+#include <mach/gpio.h>
+#include <mach/board.h>
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#define SENSOR_NAME                    "bma150"
+#define GRAVITY_EARTH                   9806550
+#define ABSMIN_2G                       (-GRAVITY_EARTH * 2)
+#define ABSMAX_2G                       (GRAVITY_EARTH * 2)
+#define BMA150_MAX_DELAY               200
+#define BMA150_CHIP_ID                 2
+#define BMA150_RANGE_SET               0
+#define BMA150_BW_SET                  4
+
+
+
+#define BMA150_CHIP_ID_REG                     0x00
+#define BMA150_X_AXIS_LSB_REG          0x02
+#define BMA150_X_AXIS_MSB_REG          0x03
+#define BMA150_Y_AXIS_LSB_REG          0x04
+#define BMA150_Y_AXIS_MSB_REG          0x05
+#define BMA150_Z_AXIS_LSB_REG          0x06
+#define BMA150_Z_AXIS_MSB_REG          0x07
+#define BMA150_STATUS_REG      0x09
+#define BMA150_CTRL_REG                0x0a
+#define BMA150_CONF1_REG       0x0b
+
+#define BMA150_CUSTOMER1_REG           0x12
+#define BMA150_CUSTOMER2_REG           0x13
+#define BMA150_RANGE_BWIDTH_REG        0x14
+#define BMA150_CONF2_REG       0x15
+
+#define BMA150_OFFS_GAIN_X_REG         0x16
+#define BMA150_OFFS_GAIN_Y_REG         0x17
+#define BMA150_OFFS_GAIN_Z_REG         0x18
+#define BMA150_OFFS_GAIN_T_REG         0x19
+#define BMA150_OFFSET_X_REG            0x1a
+#define BMA150_OFFSET_Y_REG            0x1b
+#define BMA150_OFFSET_Z_REG            0x1c
+#define BMA150_OFFSET_T_REG            0x1d
+
+#define BMA150_CHIP_ID__POS            0
+#define BMA150_CHIP_ID__MSK            0x07
+#define BMA150_CHIP_ID__LEN            3
+#define BMA150_CHIP_ID__REG            BMA150_CHIP_ID_REG
+
+/* DATA REGISTERS */
+
+#define BMA150_NEW_DATA_X__POS         0
+#define BMA150_NEW_DATA_X__LEN         1
+#define BMA150_NEW_DATA_X__MSK         0x01
+#define BMA150_NEW_DATA_X__REG         BMA150_X_AXIS_LSB_REG
+
+#define BMA150_ACC_X_LSB__POS          6
+#define BMA150_ACC_X_LSB__LEN          2
+#define BMA150_ACC_X_LSB__MSK          0xC0
+#define BMA150_ACC_X_LSB__REG          BMA150_X_AXIS_LSB_REG
+
+#define BMA150_ACC_X_MSB__POS          0
+#define BMA150_ACC_X_MSB__LEN          8
+#define BMA150_ACC_X_MSB__MSK          0xFF
+#define BMA150_ACC_X_MSB__REG          BMA150_X_AXIS_MSB_REG
+
+#define BMA150_ACC_Y_LSB__POS          6
+#define BMA150_ACC_Y_LSB__LEN          2
+#define BMA150_ACC_Y_LSB__MSK          0xC0
+#define BMA150_ACC_Y_LSB__REG          BMA150_Y_AXIS_LSB_REG
+
+#define BMA150_ACC_Y_MSB__POS          0
+#define BMA150_ACC_Y_MSB__LEN          8
+#define BMA150_ACC_Y_MSB__MSK          0xFF
+#define BMA150_ACC_Y_MSB__REG          BMA150_Y_AXIS_MSB_REG
+
+#define BMA150_ACC_Z_LSB__POS          6
+#define BMA150_ACC_Z_LSB__LEN          2
+#define BMA150_ACC_Z_LSB__MSK          0xC0
+#define BMA150_ACC_Z_LSB__REG          BMA150_Z_AXIS_LSB_REG
+
+#define BMA150_ACC_Z_MSB__POS          0
+#define BMA150_ACC_Z_MSB__LEN          8
+#define BMA150_ACC_Z_MSB__MSK          0xFF
+#define BMA150_ACC_Z_MSB__REG          BMA150_Z_AXIS_MSB_REG
+
+/* CONTROL BITS */
+
+#define BMA150_SLEEP__POS                      0
+#define BMA150_SLEEP__LEN                      1
+#define BMA150_SLEEP__MSK                      0x01
+#define BMA150_SLEEP__REG                      BMA150_CTRL_REG
+
+#define BMA150_SOFT_RESET__POS         1
+#define BMA150_SOFT_RESET__LEN         1
+#define BMA150_SOFT_RESET__MSK         0x02
+#define BMA150_SOFT_RESET__REG         BMA150_CTRL_REG
+
+#define BMA150_EE_W__POS                       4
+#define BMA150_EE_W__LEN                       1
+#define BMA150_EE_W__MSK                       0x10
+#define BMA150_EE_W__REG                       BMA150_CTRL_REG
+
+#define BMA150_UPDATE_IMAGE__POS       5
+#define BMA150_UPDATE_IMAGE__LEN       1
+#define BMA150_UPDATE_IMAGE__MSK       0x20
+#define BMA150_UPDATE_IMAGE__REG       BMA150_CTRL_REG
+
+#define BMA150_RESET_INT__POS          6
+#define BMA150_RESET_INT__LEN          1
+#define BMA150_RESET_INT__MSK          0x40
+#define BMA150_RESET_INT__REG          BMA150_CTRL_REG
+
+/* BANDWIDTH dependend definitions */
+
+#define BMA150_BANDWIDTH__POS                          0
+#define BMA150_BANDWIDTH__LEN                          3
+#define BMA150_BANDWIDTH__MSK                          0x07
+#define BMA150_BANDWIDTH__REG                          BMA150_RANGE_BWIDTH_REG
+
+/* RANGE */
+
+#define BMA150_RANGE__POS                              3
+#define BMA150_RANGE__LEN                              2
+#define BMA150_RANGE__MSK                              0x18
+#define BMA150_RANGE__REG                              BMA150_RANGE_BWIDTH_REG
+
+/* WAKE UP */
+
+#define BMA150_WAKE_UP__POS                    0
+#define BMA150_WAKE_UP__LEN                    1
+#define BMA150_WAKE_UP__MSK                    0x01
+#define BMA150_WAKE_UP__REG                    BMA150_CONF2_REG
+
+#define BMA150_WAKE_UP_PAUSE__POS              1
+#define BMA150_WAKE_UP_PAUSE__LEN              2
+#define BMA150_WAKE_UP_PAUSE__MSK              0x06
+#define BMA150_WAKE_UP_PAUSE__REG              BMA150_CONF2_REG
+
+#define BMA150_GET_BITSLICE(regvar, bitname)\
+       ((regvar & bitname##__MSK) >> bitname##__POS)
+
+
+#define BMA150_SET_BITSLICE(regvar, bitname, val)\
+       ((regvar & ~bitname##__MSK) | ((val<<bitname##__POS)&bitname##__MSK))
+
+/* range and bandwidth */
+
+#define BMA150_RANGE_2G                        0
+#define BMA150_RANGE_4G                        1
+#define BMA150_RANGE_8G                        2
+
+#define BMA150_BW_25HZ         0
+#define BMA150_BW_50HZ         1
+#define BMA150_BW_100HZ                2
+#define BMA150_BW_190HZ                3
+#define BMA150_BW_375HZ                4
+#define BMA150_BW_750HZ                5
+#define BMA150_BW_1500HZ       6
+
+/* mode settings */
+
+#define BMA150_MODE_NORMAL      0
+#define BMA150_MODE_SLEEP       2
+#define BMA150_MODE_WAKE_UP     3
+
+struct bma150acc{
+       s16     x,
+               y,
+               z;
+} ;
+static struct  {
+       int x;
+       int y;
+       int z;
+}sense_data;
+struct bma150_data {
+       struct i2c_client *bma150_client;
+       atomic_t delay;
+       atomic_t enable;
+       unsigned char mode;
+       struct input_dev *input;
+       struct bma150acc value;
+       struct mutex value_mutex;
+       struct mutex enable_mutex;
+       struct mutex mode_mutex;
+       struct delayed_work work;
+       struct work_struct irq_work;
+       struct early_suspend early_suspend;
+};
+#define RBUFF_SIZE             12      /* Rx buffer size */
+#define BMAIO                          0xA1
+
+/* IOCTLs for MMA8452 library */
+#define BMA_IOCTL_INIT                  _IO(BMAIO, 0x01)
+#define BMA_IOCTL_RESET                  _IO(BMAIO, 0x04)
+#define BMA_IOCTL_CLOSE                           _IO(BMAIO, 0x02)
+#define BMA_IOCTL_START                             _IO(BMAIO, 0x03)
+#define BMA_IOCTL_GETDATA               _IOR(BMAIO, 0x08, char[RBUFF_SIZE+1])
+
+static int bma023_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+          unsigned long arg);
+static void bma150_early_suspend(struct early_suspend *h);
+static void bma150_late_resume(struct early_suspend *h);
+
+static int bma150_smbus_read_byte(struct i2c_client *client,
+               unsigned char reg_addr, unsigned char *data)
+{
+       s32 dummy;
+       dummy = i2c_smbus_read_byte_data(client, reg_addr);
+       if (dummy < 0)
+               return -1;
+       *data = dummy & 0x000000ff;
+
+       return 0;
+}
+
+static int bma150_smbus_write_byte(struct i2c_client *client,
+               unsigned char reg_addr, unsigned char *data)
+{
+       s32 dummy;
+       dummy = i2c_smbus_write_byte_data(client, reg_addr, *data);
+       if (dummy < 0)
+               return -1;
+       return 0;
+}
+
+static int bma150_smbus_read_byte_block(struct i2c_client *client,
+               unsigned char reg_addr, unsigned char *data, unsigned char len)
+{
+       s32 dummy;
+       dummy = i2c_smbus_read_i2c_block_data(client, reg_addr, len, data);
+       if (dummy < 0)
+               return -1;
+       return 0;
+}
+
+static int bma150_set_mode(struct i2c_client *client, unsigned char Mode)
+{
+       int comres = 0;
+       unsigned char data1, data2;
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       if (client == NULL) {
+               comres = -1;
+       } else{
+               if (Mode < 4 && Mode != 1) {
+
+                       comres = bma150_smbus_read_byte(client,
+                                               BMA150_WAKE_UP__REG, &data1);
+                       data1 = BMA150_SET_BITSLICE(data1,
+                                               BMA150_WAKE_UP, Mode);
+                       comres += bma150_smbus_read_byte(client,
+                                               BMA150_SLEEP__REG, &data2);
+                       data2 = BMA150_SET_BITSLICE(data2,
+                                               BMA150_SLEEP, (Mode>>1));
+                       comres += bma150_smbus_write_byte(client,
+                                               BMA150_WAKE_UP__REG, &data1);
+                       comres += bma150_smbus_write_byte(client,
+                                               BMA150_SLEEP__REG, &data2);
+                       mutex_lock(&bma150->mode_mutex);
+                       bma150->mode = (unsigned char) Mode;
+                       mutex_unlock(&bma150->mode_mutex);
+
+               } else{
+                       comres = -1;
+               }
+       }
+
+       return comres;
+}
+
+
+static int bma150_set_range(struct i2c_client *client, unsigned char Range)
+{
+       int comres = 0;
+       unsigned char data;
+
+       if (client == NULL) {
+               comres = -1;
+       } else{
+               if (Range < 3) {
+
+                       comres = bma150_smbus_read_byte(client,
+                                               BMA150_RANGE__REG, &data);
+                       data = BMA150_SET_BITSLICE(data, BMA150_RANGE, Range);
+                       comres += bma150_smbus_write_byte(client,
+                                               BMA150_RANGE__REG, &data);
+
+               } else{
+                       comres = -1;
+               }
+       }
+
+       return comres;
+}
+
+static int bma150_get_range(struct i2c_client *client, unsigned char *Range)
+{
+       int comres = 0;
+       unsigned char data;
+
+       if (client == NULL) {
+               comres = -1;
+       } else{
+               comres = bma150_smbus_read_byte(client,
+                                               BMA150_RANGE__REG, &data);
+
+               *Range = BMA150_GET_BITSLICE(data, BMA150_RANGE);
+
+       }
+
+       return comres;
+}
+
+
+
+static int bma150_set_bandwidth(struct i2c_client *client, unsigned char BW)
+{
+       int comres = 0;
+       unsigned char data;
+
+       if (client == NULL) {
+               comres = -1;
+       } else{
+               if (BW < 8) {
+                       comres = bma150_smbus_read_byte(client,
+                                               BMA150_BANDWIDTH__REG, &data);
+                       data = BMA150_SET_BITSLICE(data, BMA150_BANDWIDTH, BW);
+                       comres += bma150_smbus_write_byte(client,
+                                               BMA150_BANDWIDTH__REG, &data);
+
+               } else{
+                       comres = -1;
+               }
+       }
+
+       return comres;
+}
+
+static int bma150_get_bandwidth(struct i2c_client *client, unsigned char *BW)
+{
+       int comres = 0;
+       unsigned char data;
+
+       if (client == NULL) {
+               comres = -1;
+       } else{
+
+
+               comres = bma150_smbus_read_byte(client,
+                                               BMA150_BANDWIDTH__REG, &data);
+
+               *BW = BMA150_GET_BITSLICE(data, BMA150_BANDWIDTH);
+
+
+       }
+
+       return comres;
+}
+
+static int bma150_read_accel_xyz(struct i2c_client *client,
+               struct bma150acc *acc)
+{
+       int comres;
+       unsigned char data[6];
+       if (client == NULL) {
+               comres = -1;
+       } else{
+
+
+               comres = bma150_smbus_read_byte_block(client,
+                                       BMA150_ACC_X_LSB__REG, &data[0], 6);
+
+               acc->x = BMA150_GET_BITSLICE(data[0], BMA150_ACC_X_LSB) |
+                       (BMA150_GET_BITSLICE(data[1], BMA150_ACC_X_MSB)<<
+                                                       BMA150_ACC_X_LSB__LEN);
+               acc->x = acc->x << (sizeof(short)*8-(BMA150_ACC_X_LSB__LEN+
+                                                       BMA150_ACC_X_MSB__LEN));
+               acc->x = acc->x >> (sizeof(short)*8-(BMA150_ACC_X_LSB__LEN+
+                                                       BMA150_ACC_X_MSB__LEN));
+
+               acc->y = BMA150_GET_BITSLICE(data[2], BMA150_ACC_Y_LSB) |
+                       (BMA150_GET_BITSLICE(data[3], BMA150_ACC_Y_MSB)<<
+                                                       BMA150_ACC_Y_LSB__LEN);
+               acc->y = acc->y << (sizeof(short)*8-(BMA150_ACC_Y_LSB__LEN +
+                                                       BMA150_ACC_Y_MSB__LEN));
+               acc->y = acc->y >> (sizeof(short)*8-(BMA150_ACC_Y_LSB__LEN +
+                                                       BMA150_ACC_Y_MSB__LEN));
+
+
+               acc->z = BMA150_GET_BITSLICE(data[4], BMA150_ACC_Z_LSB);
+               acc->z |= (BMA150_GET_BITSLICE(data[5], BMA150_ACC_Z_MSB)<<
+                                                       BMA150_ACC_Z_LSB__LEN);
+               acc->z = acc->z << (sizeof(short)*8-(BMA150_ACC_Z_LSB__LEN+
+                                                       BMA150_ACC_Z_MSB__LEN));
+               acc->z = acc->z >> (sizeof(short)*8-(BMA150_ACC_Z_LSB__LEN+
+                                                       BMA150_ACC_Z_MSB__LEN));
+
+       }
+
+       return comres;
+}
+
+static void bma150_work_func(struct work_struct *work)
+{
+       struct bma150_data *bma150 = container_of((struct delayed_work *)work,
+                       struct bma150_data, work);
+       static struct bma150acc acc;
+       s16     x,y,z;
+       unsigned long delay = msecs_to_jiffies(atomic_read(&bma150->delay));
+       struct bma023_platform_data *pdata = pdata = (bma150->bma150_client)->dev.platform_data;
+
+       bma150_read_accel_xyz(bma150->bma150_client, &acc);
+       if (pdata->swap_xyz) {
+               x = (pdata->orientation[0])*acc.x + (pdata->orientation[1])*acc.y + (pdata->orientation[2])*acc.z;
+               y = (pdata->orientation[3])*acc.x + (pdata->orientation[4])*acc.y + (pdata->orientation[5])*acc.z;
+               z = (pdata->orientation[6])*acc.x + (pdata->orientation[7])*acc.y + (pdata->orientation[8])*acc.z;
+       }
+       else {
+               x = acc.x;
+               y = acc.y;
+               z = acc.z;
+       }
+       input_report_abs(bma150->input, ABS_X, x);
+       input_report_abs(bma150->input, ABS_Y, y);
+       input_report_abs(bma150->input, ABS_Z, z);
+       input_sync(bma150->input);
+       mutex_lock(&bma150->value_mutex);
+       bma150->value = acc;
+       mutex_unlock(&bma150->value_mutex);
+       //printk("bma150_work_func   acc.x=%d,acc.y=%d,acc.z=%d\n",acc.x,acc.y,acc.z);
+       schedule_delayed_work(&bma150->work, delay);
+
+}
+
+static ssize_t bma150_mode_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       unsigned char data;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       mutex_lock(&bma150->mode_mutex);
+       data = bma150->mode;
+       mutex_unlock(&bma150->mode_mutex);
+
+       return sprintf(buf, "%d\n", data);
+}
+
+static ssize_t bma150_mode_store(struct device *dev,
+               struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       unsigned long data;
+       int error;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       error = strict_strtoul(buf, 10, &data);
+       if (error)
+               return error;
+       if (bma150_set_mode(bma150->bma150_client, (unsigned char) data) < 0)
+               return -EINVAL;
+
+
+       return count;
+}
+static ssize_t bma150_range_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       unsigned char data;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       if (bma150_get_range(bma150->bma150_client, &data) < 0)
+               return sprintf(buf, "Read error\n");
+
+       return sprintf(buf, "%d\n", data);
+}
+
+static ssize_t bma150_range_store(struct device *dev,
+               struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       unsigned long data;
+       int error;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       error = strict_strtoul(buf, 10, &data);
+       if (error)
+               return error;
+       if (bma150_set_range(bma150->bma150_client, (unsigned char) data) < 0)
+               return -EINVAL;
+
+       return count;
+}
+
+static ssize_t bma150_bandwidth_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       unsigned char data;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       if (bma150_get_bandwidth(bma150->bma150_client, &data) < 0)
+               return sprintf(buf, "Read error\n");
+
+       return sprintf(buf, "%d\n", data);
+
+}
+
+static ssize_t bma150_bandwidth_store(struct device *dev,
+               struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       unsigned long data;
+       int error;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       error = strict_strtoul(buf, 10, &data);
+       if (error)
+               return error;
+       if (bma150_set_bandwidth(bma150->bma150_client,
+                               (unsigned char) data) < 0)
+               return -EINVAL;
+
+       return count;
+}
+
+static ssize_t bma150_value_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct input_dev *input = to_input_dev(dev);
+       struct bma150_data *bma150 = input_get_drvdata(input);
+       struct bma150acc acc_value;
+
+       mutex_lock(&bma150->value_mutex);
+       acc_value = bma150->value;
+       mutex_unlock(&bma150->value_mutex);
+
+       return sprintf(buf, "%d %d %d\n", acc_value.x, acc_value.y,
+                       acc_value.z);
+}
+
+
+
+static ssize_t bma150_delay_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       return sprintf(buf, "%d\n", atomic_read(&bma150->delay));
+
+}
+
+static ssize_t bma150_delay_store(struct device *dev,
+               struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       unsigned long data;
+       int error;
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       error = strict_strtoul(buf, 10, &data);
+       if (error)
+               return error;
+       if (data > BMA150_MAX_DELAY)
+               data = BMA150_MAX_DELAY;
+       atomic_set(&bma150->delay, (unsigned int) data);
+
+       return count;
+}
+
+static ssize_t bma150_enable_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+
+       return sprintf(buf, "%d\n", atomic_read(&bma150->enable));
+
+}
+
+static void bma150_set_enable(struct device *dev, int enable)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);
+       int pre_enable = atomic_read(&bma150->enable);
+
+       mutex_lock(&bma150->enable_mutex);
+       if (enable) {
+               if (pre_enable ==0) {
+                       bma150_set_mode(bma150->bma150_client,
+                                                       BMA150_MODE_NORMAL);
+                       schedule_delayed_work(&bma150->work,
+                               msecs_to_jiffies(atomic_read(&bma150->delay)));
+                       atomic_set(&bma150->enable, 1);
+               }
+
+       } else {
+               if (pre_enable ==1) {
+                       bma150_set_mode(bma150->bma150_client,
+                                                       BMA150_MODE_SLEEP);
+                       cancel_delayed_work_sync(&bma150->work);
+                       atomic_set(&bma150->enable, 0);
+               }
+       }
+       mutex_unlock(&bma150->enable_mutex);
+
+}
+
+static ssize_t bma150_enable_store(struct device *dev,
+               struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       unsigned long data;
+       int error;
+
+       error = strict_strtoul(buf, 10, &data);
+       if (error)
+               return error;
+       if ((data == 0)||(data==1)) {
+               bma150_set_enable(dev,data);
+       }
+
+       return count;
+}
+
+static DEVICE_ATTR(range, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+               bma150_range_show, bma150_range_store);
+static DEVICE_ATTR(bandwidth, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+               bma150_bandwidth_show, bma150_bandwidth_store);
+static DEVICE_ATTR(mode, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+               bma150_mode_show, bma150_mode_store);
+static DEVICE_ATTR(value, S_IRUGO|S_IWUSR|S_IWGRP,
+               bma150_value_show, NULL);
+static DEVICE_ATTR(delay, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+               bma150_delay_show, bma150_delay_store);
+static DEVICE_ATTR(enable, S_IRUGO|S_IWUSR|S_IWGRP|S_IWOTH,
+               bma150_enable_show, bma150_enable_store);
+
+static struct attribute *bma150_attributes[] = {
+       &dev_attr_range.attr,
+       &dev_attr_bandwidth.attr,
+       &dev_attr_mode.attr,
+       &dev_attr_value.attr,
+       &dev_attr_delay.attr,
+       &dev_attr_enable.attr,
+       NULL
+};
+
+static struct attribute_group bma150_attribute_group = {
+       .attrs = bma150_attributes
+};
+
+static int bma150_input_init(struct bma150_data *bma150)
+{
+       struct input_dev *dev;
+       int err;
+
+       dev = input_allocate_device();
+       if (!dev)
+               return -ENOMEM;
+       dev->name = "gsensor";//SENSOR_NAME;
+       dev->id.bustype = BUS_I2C;
+
+       input_set_capability(dev, EV_ABS, ABS_MISC);
+       input_set_abs_params(dev, ABS_X, ABSMIN_2G, ABSMAX_2G, 0, 0);
+       input_set_abs_params(dev, ABS_Y, ABSMIN_2G, ABSMAX_2G, 0, 0);
+       input_set_abs_params(dev, ABS_Z, ABSMIN_2G, ABSMAX_2G, 0, 0);
+       input_set_drvdata(dev, bma150);
+
+       err = input_register_device(dev);
+       if (err < 0) {
+               input_free_device(dev);
+               return err;
+       }
+       bma150->input = dev;
+
+       return 0;
+}
+
+static void bma150_input_delete(struct bma150_data *bma150)
+{
+       struct input_dev *dev = bma150->input;
+
+       input_unregister_device(dev);
+       input_free_device(dev);
+}
+
+
+static int bma023_open(struct inode *inode, struct file *file)
+{
+       return 0;//nonseekable_open(inode, file);
+}
+
+static int bma023_release(struct inode *inode, struct file *file)
+{
+       return 0;
+}
+static struct file_operations bma023_fops = {
+       .owner = THIS_MODULE,
+       .open = bma023_open,
+       .release = bma023_release,
+       .unlocked_ioctl = bma023_ioctl,
+};
+static struct miscdevice bma023_device = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "mma8452_daemon",//"mma8452_daemon",
+       .fops = &bma023_fops,
+};
+static int bma023_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+          unsigned long arg)
+{
+       void __user *argp = (void __user *)arg;
+
+       struct i2c_client *client = container_of(bma023_device.parent, struct i2c_client, dev);
+       struct bma150_data *bma150 = i2c_get_clientdata(client);;
+       switch (cmd) {
+       case BMA_IOCTL_GETDATA:
+               mutex_lock(&bma150->value_mutex);
+               if(abs(sense_data.x-bma150->value.x)>10)//·À¶¶¶¯
+                       sense_data.x=bma150->value.x;
+               if(abs(sense_data.y+(bma150->value.z))>10)//·À¶¶¶¯
+                       sense_data.y=-(bma150->value.z);
+               if(abs(sense_data.z+(bma150->value.y))>10)//·À¶¶¶¯
+                       sense_data.z=-(bma150->value.y);
+              //bma150->value = acc;
+               mutex_unlock(&bma150->value_mutex);
+
+               if ( copy_to_user(argp, &sense_data, sizeof(sense_data) ) ) {
+            printk("failed to copy sense data to user space.");
+                       return -EFAULT;
+        }
+                       break;
+       default:
+               break;
+               }
+       return 0;
+}
+
+static int bma150_probe(struct i2c_client *client,
+               const struct i2c_device_id *id)
+{
+       int err = 0;
+       int tempvalue;
+       struct bma150_data *data;
+       printk(KERN_INFO "bma150_probe  \n");
+       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
+               printk(KERN_INFO "i2c_check_functionality error\n");
+               goto exit;
+       }
+       data = kzalloc(sizeof(struct bma150_data), GFP_KERNEL);
+       if (!data) {
+               err = -ENOMEM;
+               goto exit;
+       }
+
+       tempvalue = 0;
+       tempvalue = i2c_smbus_read_word_data(client, BMA150_CHIP_ID_REG);
+
+       if ((tempvalue&0x00FF) == BMA150_CHIP_ID) {
+               printk(KERN_INFO "Bosch Sensortec Device detected!\n" \
+                               "BMA150 registered I2C driver!\n");
+       } else{
+               printk(KERN_INFO "Bosch Sensortec Device not found" \
+                               "i2c error %d \n", tempvalue);
+               err = -1;
+               goto kfree_exit;
+       }
+       i2c_set_clientdata(client, data);
+       data->bma150_client = client;
+       mutex_init(&data->value_mutex);
+       mutex_init(&data->mode_mutex);
+       mutex_init(&data->enable_mutex);
+       bma150_set_bandwidth(client, BMA150_BW_SET);
+       bma150_set_range(client, BMA150_RANGE_SET);
+
+
+       INIT_DELAYED_WORK(&data->work, bma150_work_func);
+       atomic_set(&data->delay, BMA150_MAX_DELAY);
+       atomic_set(&data->enable, 0);
+       err = bma150_input_init(data);
+       if (err < 0)
+               goto kfree_exit;
+
+       err = sysfs_create_group(&data->input->dev.kobj,
+                       &bma150_attribute_group);
+       if (err < 0)
+               goto error_sysfs;
+
+       data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+       data->early_suspend.suspend = bma150_early_suspend;
+       data->early_suspend.resume = bma150_late_resume;
+       register_early_suspend(&data->early_suspend);
+       bma023_device.parent = &client->dev;
+       misc_register(&bma023_device);
+       return 0;
+
+error_sysfs:
+       bma150_input_delete(data);
+
+kfree_exit:
+       kfree(data);
+exit:
+       return err;
+}
+
+
+static int bma150_remove(struct i2c_client *client)
+{
+       struct bma150_data *data = i2c_get_clientdata(client);
+
+       bma150_set_enable(&client->dev, 0);
+       unregister_early_suspend(&data->early_suspend);
+       sysfs_remove_group(&data->input->dev.kobj, &bma150_attribute_group);
+       bma150_input_delete(data);
+       kfree(data);
+
+       return 0;
+}
+
+
+
+
+static void bma150_early_suspend(struct early_suspend *h)
+{
+       struct bma150_data *data =
+               container_of(h, struct bma150_data, early_suspend);
+
+       mutex_lock(&data->enable_mutex);
+       if (atomic_read(&data->enable)==1) {
+               bma150_set_mode(data->bma150_client, BMA150_MODE_SLEEP);
+               cancel_delayed_work_sync(&data->work);
+       }
+       mutex_unlock(&data->enable_mutex);
+}
+
+
+static void bma150_late_resume(struct early_suspend *h)
+{
+       struct bma150_data *data =
+               container_of(h, struct bma150_data, early_suspend);
+
+       mutex_lock(&data->enable_mutex);
+       if (atomic_read(&data->enable)==1) {
+               bma150_set_mode(data->bma150_client, BMA150_MODE_NORMAL);
+               schedule_delayed_work(&data->work,
+                       msecs_to_jiffies(atomic_read(&data->delay)));
+       }
+       mutex_unlock(&data->enable_mutex);
+}
+
+static const struct i2c_device_id bma150_id[] = {
+       { SENSOR_NAME, 0 },
+       { }
+};
+
+MODULE_DEVICE_TABLE(i2c, bma150_id);
+
+static struct i2c_driver bma150_driver = {
+       .driver = {
+               .owner  = THIS_MODULE,
+               .name   = SENSOR_NAME,
+       },
+       .id_table       = bma150_id,
+       .probe          = bma150_probe,
+       .remove         = bma150_remove,
+
+};
+
+static int __init BMA150_init(void)
+{
+       return i2c_add_driver(&bma150_driver);
+}
+
+static void __exit BMA150_exit(void)
+{
+       i2c_del_driver(&bma150_driver);
+}
+
+MODULE_AUTHOR("Lan Bin Yuan <lby@rock-chips.com>");
+MODULE_DESCRIPTION("BMA150 driver");
+MODULE_LICENSE("GPL");
+
+module_init(BMA150_init);
+module_exit(BMA150_exit);
index 46651a24969522877b48b62236f455eb1ca38163..1a362c11bf68b633d720374abe78cefa6865f7f2 100755 (executable)
@@ -18,6 +18,9 @@ config INPUT_LPSENSOR_ISL29028
 config INPUT_LPSENSOR_CM3602
        tristate "l/p sensor input support"
 
+config INPUT_LPSENSOR_AL3006
+       tristate "al3006 l/p sensor input support"
+
 config INPUT_88PM860X_ONKEY
        tristate "88PM860x ONKEY support"
        depends on MFD_88PM860X
index d17fcab89d6196bf2e23d40bcfc9ab7225d3f160..3b6e7b0e262b5c506dc09005142c8f623a51b021 100755 (executable)
@@ -49,4 +49,5 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)      += wistron_btns.o
 obj-$(CONFIG_INPUT_WM831X_ON)          += wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)        += xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)            += yealink.o
+obj-$(CONFIG_INPUT_LPSENSOR_AL3006)    += al3006.o
 
diff --git a/drivers/input/misc/al3006.c b/drivers/input/misc/al3006.c
new file mode 100644 (file)
index 0000000..e11291b
--- /dev/null
@@ -0,0 +1,833 @@
+/* drivers/input/misc/al3006.c
+ *
+ * Copyright (C) 2010 ROCK-CHIPS, Inc.
+ * Author: eric <hc@rock-chips.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/miscdevice.h>
+#include <linux/circ_buf.h>
+#include <linux/interrupt.h>
+#include "al3006.h"
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#include <linux/delay.h>
+#include <linux/wait.h>
+
+#define AL3006_DBG 0
+
+#if AL3006_DBG
+#define AL3006_DEBUG(x...) printk(x)
+#else
+#define AL3006_DEBUG(x...)
+#endif
+
+#define CONFIG_REG        (0x00)
+#define TIM_CTL_REG       (0x01)
+#define ALS_CTL_REG       (0x02)
+#define INT_STATUS_REG    (0x03)
+#define PS_CTL_REG        (0x04)
+#define PS_ALS_DATA_REG   (0x05)
+#define ALS_WINDOWS_REG   (0x08)
+
+//enable bit[ 0-1], in register CONFIG_REG
+#define ONLY_ALS_EN       (0x00)
+#define ONLY_PROX_EN      (0x01)
+#define ALL_PROX_ALS_EN   (0x02)
+#define ALL_IDLE          (0x03)
+
+#define POWER_MODE_MASK   (0x0C)
+#define POWER_UP_MODE     (0x00)
+#define POWER_DOWN_MODE   (0x08)
+#define POWER_RESET_MODE  (0x0C)
+
+struct al3006_data {
+       struct input_dev         *psensor_input_dev;
+       struct input_dev         *lsensor_input_dev;
+       struct i2c_client        *client;
+       struct delayed_work      dwork; //for l/psensor
+       //struct delayed_work    l_work; //for light sensor
+       struct mutex lock;
+       int enabled;
+       int irq;
+};
+static struct al3006_data al3006_struct_data;
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static struct early_suspend al3006_early_suspend;
+#endif
+
+int g_lightlevel = 8;
+
+static const int luxValues[8] = {
+               10, 160, 225, 320,
+               640, 1280, 2600, 4095
+};
+
+
+static int al3006_read_reg(struct i2c_client *client, char reg, char *value)
+{
+       int ret = 0;
+       struct i2c_msg msg[2];
+       struct i2c_adapter *adap = client->adapter;
+
+       msg[0].addr  = client->addr;
+       msg[0].flags = client->flags;
+       msg[0].len = 1;
+       msg[0].buf = (char *)&reg;
+       msg[0].scl_rate = 400 * 1000;
+
+       msg[1].addr  = client->addr;
+       msg[1].flags = client->flags | I2C_M_RD;
+       msg[1].len = 1;
+       msg[1].buf = (char *)value;
+       msg[1].scl_rate = 400 * 1000;
+
+       if ((ret = i2c_transfer(adap, (struct i2c_msg *)&msg, 2)) < 2) {
+               AL3006_DEBUG("%s: read al3006 register  %#x failure\n", __FUNCTION__, reg);
+               return -EIO;
+       }
+
+       return 1;
+}
+
+static int al3006_write_reg(struct i2c_client *client, char reg, char value)
+{
+       int ret = 0;
+       char buf[2];
+       struct i2c_msg msg;
+       struct i2c_adapter *adap = client->adapter;
+
+       buf[0] = reg;
+       buf[1] = value;
+
+       msg.addr  = client->addr;
+       msg.flags = client->flags;
+       msg.len = 2;
+       msg.buf = (char *)&buf;
+       msg.scl_rate = 400 * 1000;
+
+
+       if ((ret = i2c_transfer(adap, (struct i2c_msg *)&msg, 1)) < 1) {
+               AL3006_DEBUG("%s: read al3006 register  %#x failure\n", __FUNCTION__, reg);
+               return -EIO;
+       }
+
+       return 1;
+}
+
+static void al3006_change_ps_threshold(struct i2c_client *client)
+{
+       struct al3006_data *al3006 = i2c_get_clientdata(client);
+       char reg, value;
+
+       AL3006_DEBUG("%s:\n", __FUNCTION__);
+       mutex_lock(&al3006->lock);
+       reg = PS_ALS_DATA_REG;
+       al3006_read_reg(client, reg, &value);
+       mutex_unlock(&al3006->lock);
+
+       value >>= 7;  //bit7 is ps data ; bit7 = 1, object is detected
+       printk("%s: psensor's data is %#x\n", __FUNCTION__, value);
+
+       input_report_abs(al3006->psensor_input_dev, ABS_DISTANCE, value?0:1);
+       input_sync(al3006->psensor_input_dev);
+}
+
+static void al3006_change_ls_threshold(struct i2c_client *client)
+{
+       struct al3006_data *al3006 = i2c_get_clientdata(client);
+       char reg, value;
+
+       AL3006_DEBUG("%s:\n", __FUNCTION__);
+       mutex_lock(&al3006->lock);
+       reg = PS_ALS_DATA_REG;
+       al3006_read_reg(client, reg, &value);
+       mutex_unlock(&al3006->lock);
+
+       value &= 0x3F; // bit0-5  is ls data;
+       printk("%s: lightsensor's level is %#x\n", __FUNCTION__, value);
+
+       if(value > 8) value = 8;
+       input_report_abs(al3006->lsensor_input_dev, ABS_MISC, value);
+       input_sync(al3006->lsensor_input_dev);
+}
+
+static void al3006_work_handler(struct work_struct *work)
+{
+       struct al3006_data *al3006 = (struct al3006_data *)container_of(work, struct al3006_data, dwork.work);
+       char reg, value;
+
+       mutex_lock(&al3006->lock);
+       reg = INT_STATUS_REG;
+       al3006_read_reg(al3006->client, reg, &value);
+       mutex_unlock(&al3006->lock);
+       AL3006_DEBUG("%s: INT_STATUS_REG is %#x\n", __FUNCTION__, value);
+
+       value &= 0x03;
+       if(value == 0x02) {        //ps int
+               al3006_change_ps_threshold(al3006->client);
+       }
+       else if(value == 0x01) {   //ls int
+               al3006_change_ls_threshold(al3006->client);
+       }
+       else if(value == 0x03) {   //ps and ls int
+               al3006_change_ps_threshold(al3006->client);
+               al3006_change_ls_threshold(al3006->client);
+       }
+       //enable_irq(al3006->irq);
+}
+
+static void al3006_reschedule_work(struct al3006_data *data,
+                                         unsigned long delay)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&data->lock, flags);
+
+       /*
+        * If work is already scheduled then subsequent schedules will not
+        * change the scheduled time that's why we have to cancel it first.
+        */
+       __cancel_delayed_work(&data->dwork);
+       schedule_delayed_work(&data->dwork, delay);
+
+       spin_unlock_irqrestore(&data->lock, flags);
+}
+
+static irqreturn_t al3006_irq_handler(int irq, void *data)
+{
+       struct al3006_data *al3006 = (struct al3006_data *)data;
+       AL3006_DEBUG("%s\n", __FUNCTION__);
+       //input_report_abs(al3006->psensor_input_dev, ABS_DISTANCE, 0);
+       //input_sync(al3006->psensor_input_dev);
+
+       //disable_irq_nosync(al3006->irq);
+       al3006_reschedule_work(al3006, 0);//msecs_to_jiffies(420)
+
+       return IRQ_HANDLED;
+}
+
+static int al3006_psensor_enable(struct i2c_client *client)
+{
+       char reg, value;
+       int ret;
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+       AL3006_DEBUG("%s:\n", __FUNCTION__);
+       mutex_lock(&al3006->lock);
+       reg = CONFIG_REG;
+       ret = al3006_read_reg(client, reg, &value);
+       if( (value & 0x03) == ONLY_ALS_EN ){
+               value &= ~0x03;
+               value |= ALL_PROX_ALS_EN;
+               ret = al3006_write_reg(client, reg, value);
+       }
+       else if( (value & 0x03) == ALL_IDLE ){
+               value &= ~0x03;
+               value |= ONLY_PROX_EN;
+               ret = al3006_write_reg(client, reg, value);
+       }
+#ifdef AL3006_DBG
+       ret = al3006_read_reg(client, reg, &value);
+       AL3006_DEBUG("%s: configure reg value %#x ...\n", __FUNCTION__, value);
+#endif
+
+       reg = PS_ALS_DATA_REG;
+       al3006_read_reg(client, reg, &value);
+
+       value >>= 7;  //bit7 is ps data ; bit7 = 1, object is detected
+       printk("%s: psensor's data is %#x\n", __FUNCTION__, value);
+
+       input_report_abs(al3006->psensor_input_dev, ABS_DISTANCE, value?0:1);
+       input_sync(al3006->psensor_input_dev);
+       mutex_unlock(&al3006->lock);
+
+       //enable_irq(al3006->irq);
+
+       return ret;
+}
+
+static int al3006_psensor_disable(struct i2c_client *client)
+{
+       char ret, reg, value;
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+       mutex_lock(&al3006->lock);
+       reg = CONFIG_REG;
+       ret = al3006_read_reg(client, reg, &value);
+       if( (value & 0x03) == ONLY_PROX_EN ){
+               value &= ~0x03;
+               value |= ALL_IDLE;
+               ret = al3006_write_reg(client, reg, value);
+       }
+       else if( (value & 0x03) == ALL_PROX_ALS_EN ){
+               value &= ~0x03;
+               value |= ONLY_ALS_EN;
+               ret = al3006_write_reg(client, reg, value);
+       }
+#ifdef AL3006_DBG
+       ret = al3006_read_reg(client, reg, &value);
+       AL3006_DEBUG("%s: configure reg value %#x ...\n", __FUNCTION__, value);
+#endif
+       mutex_unlock(&al3006->lock);
+
+       //disable_irq(al3006->irq);
+       //cancel_delayed_work_sync(&al3006->dwork);
+       //enable_irq(al3006->irq);
+
+       return ret;
+}
+
+static int misc_ps_opened = 0;
+
+static int al3006_psensor_open(struct inode *inode, struct file *file)
+{
+//     struct i2c_client *client =
+//                    container_of (al3006_psensor_misc.parent, struct i2c_client, dev);
+       printk("%s\n", __func__);
+       if (misc_ps_opened)
+               return -EBUSY;
+       misc_ps_opened = 1;
+       return 0;
+}
+
+static int al3006_psensor_release(struct inode *inode, struct file *file)
+{
+//     struct i2c_client *client =
+//                    container_of (al3006_psensor_misc.parent, struct i2c_client, dev);
+       printk("%s\n", __func__);
+       misc_ps_opened = 0;
+       return 0;
+}
+
+static long al3006_psensor_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       char reg, val, enabled;
+       struct al3006_data *al3006 = &al3006_struct_data;
+       struct i2c_client *client = al3006->client;
+
+       printk("%s cmd %d\n", __func__, _IOC_NR(cmd));
+       switch (cmd) {
+       case PSENSOR_IOCTL_ENABLE:
+               if (get_user(val, (unsigned long __user *)arg))
+                       return -EFAULT;
+               if (val)
+                       return al3006_psensor_enable(client);
+               else
+                       return al3006_psensor_disable(client);
+               break;
+       case PSENSOR_IOCTL_GET_ENABLED:
+               mutex_lock(&al3006->lock);
+               reg = CONFIG_REG;
+               al3006_read_reg(client, reg, &val);
+               mutex_unlock(&al3006->lock);
+               val &= 0x03;
+               if(val == ONLY_PROX_EN || val == ALL_PROX_ALS_EN)
+                       enabled = 1;
+               else
+                       enabled = 0;
+               return put_user(enabled, (unsigned long __user *)arg);
+               break;
+       default:
+               pr_err("%s: invalid cmd %d\n", __func__, _IOC_NR(cmd));
+               return -EINVAL;
+       }
+}
+
+static struct file_operations al3006_psensor_fops = {
+       .owner = THIS_MODULE,
+       .open = al3006_psensor_open,
+       .release = al3006_psensor_release,
+       .unlocked_ioctl = al3006_psensor_ioctl
+};
+
+static struct miscdevice al3006_psensor_misc = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "psensor",
+       .fops = &al3006_psensor_fops
+};
+
+static int register_psensor_device(struct i2c_client *client, struct al3006_data *data)
+{
+       struct input_dev *input_dev = data->psensor_input_dev;
+       int rc;
+
+       AL3006_DEBUG("%s: allocating input device psensor\n", __func__);
+       input_dev = input_allocate_device();
+       if (!input_dev) {
+               dev_err(&client->dev,"%s: could not allocate input device for psensor\n", __FUNCTION__);
+               rc = -ENOMEM;
+               goto done;
+       }
+       data->psensor_input_dev = input_dev;
+       input_set_drvdata(input_dev, data);
+
+       input_set_drvdata(input_dev, data);
+       input_dev->name = "proximity";
+       set_bit(EV_ABS, input_dev->evbit);
+       input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1, 0, 0);
+
+       AL3006_DEBUG("%s: registering input device psensor\n", __FUNCTION__);
+       rc = input_register_device(input_dev);
+       if (rc < 0) {
+               pr_err("%s: could not register input device for psensor\n", __FUNCTION__);
+               goto done;
+       }
+
+       AL3006_DEBUG("%s: registering misc device for psensor\n", __FUNCTION__);
+       rc = misc_register(&al3006_psensor_misc);
+       if (rc < 0) {
+               pr_err("%s: could not register misc device psensor\n", __FUNCTION__);
+               goto err_unregister_input_device;
+       }
+       al3006_psensor_misc.parent = &client->dev;
+
+       //INIT_DELAYED_WORK(&data->p_work, al3006_psensor_work_handler);
+
+       return 0;
+
+err_unregister_input_device:
+       input_unregister_device(input_dev);
+done:
+       return rc;
+}
+
+static void unregister_psensor_device(struct i2c_client *client, struct al3006_data *data)
+{
+       misc_deregister(&al3006_psensor_misc);
+       input_unregister_device(data->psensor_input_dev);
+}
+
+#define LSENSOR_POLL_PROMESHUTOK   1000
+
+static int al3006_lsensor_enable(struct i2c_client *client)
+{
+       char reg, value;
+       int ret;
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+       mutex_lock(&al3006->lock);
+
+       reg = CONFIG_REG;
+       ret = al3006_read_reg(client, reg, &value);
+       if( (value & 0x03) == ONLY_PROX_EN ){
+               value &= ~0x03;
+               value |= ALL_PROX_ALS_EN;
+               ret = al3006_write_reg(client, reg, value);
+       }
+       else if( (value & 0x03) == ALL_IDLE ){
+               value &= ~0x03;
+               value |= ONLY_ALS_EN;
+               ret = al3006_write_reg(client, reg, value);
+       }
+#ifdef AL3006_DBG
+       ret = al3006_read_reg(client, reg, &value);
+       AL3006_DEBUG("%s: configure reg value %#x ...\n", __FUNCTION__, value);
+#endif
+
+       mutex_unlock(&al3006->lock);
+
+       //schedule_delayed_work(&(al3006->l_work), msecs_to_jiffies(LSENSOR_POLL_PROMESHUTOK));
+
+       return ret;
+}
+
+static int al3006_lsensor_disable(struct i2c_client *client)
+{
+       char ret, reg, value;
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+       //cancel_delayed_work_sync(&(al3006->l_work));
+
+       mutex_lock(&al3006->lock);
+       reg = CONFIG_REG;
+       ret = al3006_read_reg(client, reg, &value);
+       if( (value & 0x03) == ONLY_ALS_EN ){
+               value &= ~0x03;
+               value |= ALL_IDLE;
+               ret = al3006_write_reg(client, reg, value);
+       }
+       else if( (value & 0x03) == ALL_PROX_ALS_EN ){
+               value &= ~0x03;
+               value |= ONLY_PROX_EN;
+               ret = al3006_write_reg(client, reg, value);
+       }
+#ifdef AL3006_DBG
+       ret = al3006_read_reg(client, reg, &value);
+       AL3006_DEBUG("%s: configure reg value %#x ...\n", __FUNCTION__, value);
+#endif
+       mutex_unlock(&al3006->lock);
+
+       return ret;
+}
+
+static int luxValue_to_level(int value)
+{
+       int i;
+       if (value >= luxValues[7])
+               return 7;
+       if (value <= luxValues[0])
+               return 0;
+       for (i=0;i<7;i++)
+               if (value>=luxValues[i] && value<luxValues[i+1])
+                       return i;
+       return -1;
+}
+
+static int misc_ls_opened = 0;
+
+static int al3006_lsensor_open(struct inode *inode, struct file *file)
+{
+//     struct i2c_client *client =
+//                    container_of (al3006_lsensor_misc.parent, struct i2c_client, dev);
+       printk("%s\n", __func__);
+       if (misc_ls_opened)
+               return -EBUSY;
+       misc_ls_opened = 1;
+       return 0;
+}
+
+static int al3006_lsensor_release(struct inode *inode, struct file *file)
+{
+
+//     struct i2c_client *client =
+//                    container_of (al3006_lsensor_misc.parent, struct i2c_client, dev);
+       printk("%s\n", __func__);
+       misc_ls_opened = 0;
+       return 0;
+}
+
+static long al3006_lsensor_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       char reg, val, enabled;
+       struct al3006_data *al3006 = &al3006_struct_data;
+       struct i2c_client *client = al3006->client;
+
+       printk("%s cmd %d\n", __FUNCTION__, _IOC_NR(cmd));
+       switch (cmd) {
+       case LIGHTSENSOR_IOCTL_ENABLE:
+               if (get_user(val, (unsigned long __user *)arg))
+                       return -EFAULT;
+               if (val)
+                       return al3006_lsensor_enable(client);
+               else
+                       return al3006_lsensor_disable(client);
+               break;
+       case LIGHTSENSOR_IOCTL_GET_ENABLED:
+               mutex_lock(&al3006->lock);
+               reg =CONFIG_REG;
+               al3006_read_reg(client, reg, &val);
+               mutex_unlock(&al3006->lock);
+               val &= 0x03;
+               if(val == ONLY_ALS_EN || val == ALL_PROX_ALS_EN)
+                       enabled = 1;
+               else
+                       enabled = 0;
+               return put_user(enabled, (unsigned long __user *)arg);
+               break;
+       default:
+               pr_err("%s: invalid cmd %d\n", __func__, _IOC_NR(cmd));
+               return -EINVAL;
+       }
+}
+
+static struct file_operations al3006_lsensor_fops = {
+       .owner = THIS_MODULE,
+       .open = al3006_lsensor_open,
+       .release = al3006_lsensor_release,
+       .unlocked_ioctl = al3006_lsensor_ioctl
+};
+
+static struct miscdevice al3006_lsensor_misc = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "lightsensor",
+       .fops = &al3006_lsensor_fops
+};
+
+static int register_lsensor_device(struct i2c_client *client, struct al3006_data *data)
+{
+       struct input_dev *input_dev = data->lsensor_input_dev;
+       int rc;
+
+       AL3006_DEBUG("%s: allocating input device lsensor\n", __func__);
+       input_dev = input_allocate_device();
+       if (!input_dev) {
+               dev_err(&client->dev,"%s: could not allocate input device for lsensor\n", __FUNCTION__);
+               rc = -ENOMEM;
+               goto done;
+       }
+       data->lsensor_input_dev = input_dev;
+       input_set_drvdata(input_dev, data);
+
+       input_set_drvdata(input_dev, data);
+       input_dev->name = "lightsensor-level";
+       set_bit(EV_ABS, input_dev->evbit);
+       input_set_abs_params(input_dev, ABS_MISC, 0, 8, 0, 0);
+
+       AL3006_DEBUG("%s: registering input device al3006 lsensor\n", __FUNCTION__);
+       rc = input_register_device(input_dev);
+       if (rc < 0) {
+               pr_err("%s: could not register input device for lsensor\n", __FUNCTION__);
+               goto done;
+       }
+
+       AL3006_DEBUG("%s: registering misc device for al3006's lsensor\n", __FUNCTION__);
+       rc = misc_register(&al3006_lsensor_misc);
+       if (rc < 0) {
+               pr_err("%s: could not register misc device lsensor\n", __FUNCTION__);
+               goto err_unregister_input_device;
+       }
+
+       al3006_lsensor_misc.parent = &client->dev;
+
+       //INIT_DELAYED_WORK(&data->l_work, al3006_lsensor_work_handler);
+
+       return 0;
+
+err_unregister_input_device:
+       input_unregister_device(input_dev);
+done:
+       return rc;
+}
+
+static void unregister_lsensor_device(struct i2c_client *client, struct al3006_data *al3006)
+{
+       misc_deregister(&al3006_lsensor_misc);
+       input_unregister_device(al3006->lsensor_input_dev);
+}
+
+static int al3006_config(struct i2c_client *client)
+{
+       char value;
+       //struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+       AL3006_DEBUG("%s: init al3006 all register\n", __FUNCTION__);
+
+    /***********************config**************************/
+       value = 0x41;//The ADC effective resolution = 9;  Low lux threshold level = 1;
+       //value = 0x69; //The ADC effective resolution = 17;  Low lux threshold level = 9;
+       al3006_write_reg(client, ALS_CTL_REG, value);
+
+       //value = 0x04;//0x01-0x0f; 17%->93.5% if value = 0x04,then Compensate Loss 52%
+       value = 0x02;//0x01-0x0f; 17%->93.5% if value = 0x02,then Compensate Loss 31%
+       al3006_write_reg(client, ALS_WINDOWS_REG, value);
+
+       return 0;
+}
+void disable_al3006_device(struct i2c_client *client)
+{
+       char value;
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+#if 0
+       mutex_lock(&al3006->lock);
+       al3006_read_reg(client, CONFIG_REG, &value);
+       value &= ~POWER_MODE_MASK;
+       value |= POWER_DOWN_MODE;
+       al3006_write_reg(client, CONFIG_REG, value);
+       mutex_unlock(&al3006->lock);
+#endif
+       mutex_lock(&al3006->lock);
+       al3006_write_reg(client, CONFIG_REG, 0x0B);
+       al3006_read_reg(client, CONFIG_REG, &value);
+       mutex_unlock(&al3006->lock);
+       AL3006_DEBUG("%s: value = 0x%x\n", __FUNCTION__,value);
+}
+
+void enable_al3006_device(struct i2c_client *client)
+{
+       char value;
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+
+       mutex_lock(&al3006->lock);
+       al3006_read_reg(client, CONFIG_REG, &value);
+       value &= ~POWER_MODE_MASK;
+       value |= POWER_UP_MODE;
+       al3006_write_reg(client, CONFIG_REG, value);
+       al3006_read_reg(client, CONFIG_REG, &value);
+       mutex_unlock(&al3006->lock);
+
+       AL3006_DEBUG("%s: value = 0x%x\n", __FUNCTION__,value);
+#if 0
+       mutex_lock(&al3006->lock);
+       al3006_write_reg(client, CONFIG_REG, 0x03);
+       mutex_unlock(&al3006->lock);
+#endif
+
+}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void al3006_suspend(struct early_suspend *h)
+{
+       struct i2c_client *client = container_of(al3006_psensor_misc.parent, struct i2c_client, dev);
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+       printk("al3006 early suspend ========================= \n");
+
+       if (misc_ls_opened)
+               al3006_lsensor_disable(client);
+       if (misc_ps_opened)
+               //al3006_psensor_disable(client);
+               enable_irq_wake(al3006->irq);
+       else
+               disable_al3006_device(client);
+
+
+       //disable_al3006_device(client);
+}
+
+static void al3006_resume(struct early_suspend *h)
+{
+       struct i2c_client *client = container_of(al3006_psensor_misc.parent, struct i2c_client, dev);
+       struct al3006_data *al3006 = (struct al3006_data *)i2c_get_clientdata(client);
+    printk("al3006 early resume ======================== \n");
+
+       if (misc_ps_opened)
+               //al3006_psensor_enable(client);
+               disable_irq_wake(al3006->irq);
+       if (misc_ls_opened)
+               al3006_lsensor_enable(client);
+
+       enable_al3006_device(client);
+}
+#else
+#define al3006_suspend NULL
+#define al3006_resume NULL
+#endif
+
+static int al3006_probe(struct i2c_client *client, const struct i2c_device_id *id)
+{
+       struct al3006_data *al3006 = &al3006_struct_data;
+       int rc = -EIO;
+       char value = 0;
+
+       printk("\n%s: al3006 i2c client probe\n\n", __FUNCTION__);
+       al3006_read_reg(client, CONFIG_REG, &value);
+       printk("\n%s: al3006's CONFIG_REG value =  0x%x\n", __FUNCTION__, value);
+
+       al3006->client = client;
+       i2c_set_clientdata(client, al3006);
+       mutex_init(&al3006->lock);
+
+       rc = register_psensor_device(client, al3006);
+       if (rc) {
+               dev_err(&client->dev, "failed to register_psensor_device\n");
+               goto done;
+       }
+
+       rc = register_lsensor_device(client, al3006);
+       if (rc) {
+               dev_err(&client->dev, "failed to register_lsensor_device\n");
+               goto unregister_device1;
+       }
+
+       rc = al3006_config(client);
+       if (rc) {
+               dev_err(&client->dev, "failed to al3006_config\n");
+               goto unregister_device2;
+       }
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+       al3006_early_suspend.suspend = al3006_suspend;
+       al3006_early_suspend.resume  = al3006_resume;
+       al3006_early_suspend.level   = 0x02;
+       register_early_suspend(&al3006_early_suspend);
+#endif
+
+       INIT_DELAYED_WORK(&al3006->dwork, al3006_work_handler);
+
+       rc = gpio_request(client->irq, "al3006 irq");
+       if (rc) {
+               pr_err("%s: request gpio %d for al3006 irq failed \n", __FUNCTION__, client->irq);
+               goto unregister_device2;
+       }
+       rc = gpio_direction_input(client->irq);
+       if (rc) {
+               pr_err("%s: failed set gpio input\n", __FUNCTION__);
+       }
+       gpio_pull_updown(client->irq, GPIOPullUp);
+       al3006->irq = gpio_to_irq(client->irq);
+       mdelay(1);
+       rc = request_irq(al3006->irq, al3006_irq_handler,
+                                       IRQ_TYPE_EDGE_FALLING, client->name, (void *)al3006);//IRQ_TYPE_LEVEL_LOW
+       if (rc < 0) {
+               dev_err(&client->dev,"request_irq failed for gpio %d (%d)\n", client->irq, rc);
+               goto err_free_gpio;
+       }
+
+       //al3006_psensor_enable(client);
+       //al3006_lsensor_enable(client);
+
+       return 0;
+
+err_free_gpio:
+       gpio_free(client->irq);
+unregister_device2:
+       unregister_lsensor_device(client, &al3006_struct_data);
+unregister_device1:
+       unregister_psensor_device(client, &al3006_struct_data);
+done:
+       return rc;
+}
+
+static int al3006_remove(struct i2c_client *client)
+{
+       struct al3006_data *data = i2c_get_clientdata(client);
+
+       unregister_psensor_device(client, data);
+       unregister_lsensor_device(client, data);
+#ifdef CONFIG_HAS_EARLYSUSPEND
+    unregister_early_suspend(&al3006_early_suspend);
+#endif
+       return 0;
+}
+
+static const struct i2c_device_id al3006_id[] = {
+               {"al3006", 0},
+               { }
+};
+
+static struct i2c_driver al3006_driver = {
+       .driver = {
+               .name = "al3006",
+       },
+       .probe    = al3006_probe,
+       .remove   = al3006_remove,
+       .id_table = al3006_id,
+
+};
+
+static int __init al3006_init(void)
+{
+
+       return i2c_add_driver(&al3006_driver);
+}
+
+static void __exit al3006_exit(void)
+{
+       return i2c_del_driver(&al3006_driver);
+}
+
+module_init(al3006_init);
+module_exit(al3006_exit);
diff --git a/drivers/input/misc/al3006.h b/drivers/input/misc/al3006.h
new file mode 100644 (file)
index 0000000..30e084c
--- /dev/null
@@ -0,0 +1,33 @@
+/* include/linux/isl29028.h
+ *
+ * Copyright (C) 2009 Google, Inc.
+ * Author: Iliyan Malchev <malchev@google.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ *
+ */
+
+#ifndef __LINUX_AL3006_H
+#define __LINUX_AL3006_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define PSENSOR_IOCTL_MAGIC 'c'
+#define PSENSOR_IOCTL_GET_ENABLED \
+               _IOR(PSENSOR_IOCTL_MAGIC, 1, int *)
+#define PSENSOR_IOCTL_ENABLE \
+               _IOW(PSENSOR_IOCTL_MAGIC, 2, int *)
+
+#define LIGHTSENSOR_IOCTL_MAGIC 'l'
+#define LIGHTSENSOR_IOCTL_GET_ENABLED _IOR(LIGHTSENSOR_IOCTL_MAGIC, 1, int *)
+#define LIGHTSENSOR_IOCTL_ENABLE _IOW(LIGHTSENSOR_IOCTL_MAGIC, 2, int *)
+
+#endif
index ecf1ee807473ca4b77004b720fba2cdab58d3a4b..212a2a3e6a1a03c3a3d327f8bffae06b68f23f73 100755 (executable)
@@ -961,6 +961,10 @@ config TOUCHSCREEN_GT818_IIC
        tristate "GT818_IIC based touchscreens"
        depends on I2C2_RK29
 
+config TOUCHSCREEN_PIXCIR
+       tristate "PIXCIR_IIC based touchscreens"
+       depends on I2C2_RK29
+
 config D70_L3188A
        tristate "D70-L3188A based touchscreens"
        depends on I2C2_RK29
index 2e8035d6baad003addfdf72c67be131fc94e93f7..94e802ad900fd6874523257912a94d56a1a31f4a 100755 (executable)
@@ -83,3 +83,4 @@ obj-$(CONFIG_TOUCHSCREEN_FT5406)      += ft5406_ts.o
 obj-$(CONFIG_TOUCHSCREEN_GT819)                += gt819.o
 obj-$(CONFIG_TOUCHSCREEN_NAS)          += nas_ts.o
 obj-$(CONFIG_LAIBAO_TS)                += ft5x0x_i2c_ts.o
+obj-$(CONFIG_TOUCHSCREEN_PIXCIR)      += pixcir_i2c_ts.o
index ee5624b39cd79a1eed1398cb2d4346e21aab8e85..af0c5f0ed8e440275d9224161d164d145c7d29e0 100755 (executable)
@@ -376,7 +376,6 @@ static void ProcessReport(unsigned char *buf, int buflen)
                                input_mt_slot(input_dev, i);
                                input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, true);
                                input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, PointBuf[i].Status);
-                               input_report_abs(input_dev, ABS_MT_PRESSURE, 100);
                                input_report_abs(input_dev, ABS_MT_POSITION_X, PointBuf[i].X);
                                input_report_abs(input_dev, ABS_MT_POSITION_Y, PointBuf[i].Y);
 
@@ -421,7 +420,6 @@ static struct input_dev * allocate_Input_Dev(void)
        input_set_abs_params(pInputDev, ABS_MT_POSITION_X, 0, CONFIG_EETI_EGALAX_MAX_X, 0, 0);
        input_set_abs_params(pInputDev, ABS_MT_POSITION_Y, 0, CONFIG_EETI_EGALAX_MAX_Y, 0, 0);
        input_set_abs_params(pInputDev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
-       input_set_abs_params(pInputDev, ABS_MT_PRESSURE, 0, 255, 0, 0);
 
        ret = input_register_device(pInputDev);
        if(ret) 
@@ -503,7 +501,6 @@ static void egalax_i2c_wq(struct work_struct *work)
                                input_mt_slot(input_dev, i);
                                input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, true);
                                input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 0);
-                               input_report_abs(input_dev, ABS_MT_PRESSURE, 100);
                                input_report_abs(input_dev, ABS_MT_POSITION_X, PointBuf[i].X);
                                input_report_abs(input_dev, ABS_MT_POSITION_Y, PointBuf[i].Y);
                                PointBuf[i].Status = 0;
index 4a447f7d4750a1a6d88851134b4d8ce2ac4ef997..8dd6b5d20f94279ae9d52c8c1bd7d88d066821b9 100644 (file)
@@ -350,8 +350,9 @@ static void goodix_ts_work_func(struct work_struct *work)
                        syn_flag = 1;\r
                }\r
 \r
-               input_sync(ts->input_dev);\r
-       }\r
+}\r
+input_sync(ts->input_dev);\r
+\r
 \r
 \r
 #ifdef HAVE_TOUCH_KEY\r
index d95e9bc22c00b51b6d02efe0d87d61bf8d4394ec..ff3775d646be6f6eb0e7e262f1ff158ead935f37 100755 (executable)
@@ -298,11 +298,13 @@ static int verify_coord(struct ili2102_ts_data *ts,unsigned int *x,unsigned int
 {
 
        //DBG("%s:(%d/%d)\n",__FUNCTION__,*x, *y);
+       #ifndef CONFIG_MACH_RK29_TD8801_V2
        if((*x< ts->x_min) || (*x > ts->x_max))
                return -1;
 
        if((*y< ts->y_min) || (*y > ts->y_max))
                return -1;
+    #endif
 
        /*android do not support min and max value*/
        if(*x == ts->x_min)
@@ -398,7 +400,10 @@ static void ili2102_ts_work_func(struct work_struct *work)
                                        x = g_x[i];
                                        y = g_y[i];
                                }
-
+                               #ifdef CONFIG_MACH_RK29_TD8801_V2
+                               if( y >=80 ) y-=80;
+                               if( x >= 50 ) x-=50;
+                               #endif
                                g_x[i] = x;
                                g_y[i] = y;                     
                                input_event(ts->input_dev, EV_ABS, ABS_MT_TRACKING_ID, i);
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
new file mode 100644 (file)
index 0000000..cdd5c83
--- /dev/null
@@ -0,0 +1,920 @@
+/*
+ * Driver for Pixcir I2C touchscreen controllers.
+ *
+ * Copyright (C) 2010-2011 Pixcir, Inc.
+ *
+ * pixcir_i2c_ts.c V3.0  from v3.0 support TangoC solution and remove the previous soltutions
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/earlysuspend.h>
+#include <linux/hrtimer.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/input/mt.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/gpio.h>
+#include <mach/iomux.h>
+#include <linux/platform_device.h>
+
+#include <linux/slab.h>
+#include <asm/uaccess.h>
+#include <linux/proc_fs.h>
+
+#include "pixcir_i2c_ts.h"
+
+#define PIXCIR_DEBUG                   0
+#if PIXCIR_DEBUG
+       #define pixcir_dbg(msg...)      printk(msg);
+#else
+       #define pixcir_dbg(msg...)
+#endif
+
+static int  ts_dbg_enable = 0;
+
+#define DBG(msg...) \
+       ({if(ts_dbg_enable == 1) printk(msg);})
+/*********************************Bee-0928-TOP****************************************/
+
+#define SLAVE_ADDR             0x5c
+
+#ifndef I2C_MAJOR
+#define I2C_MAJOR              125
+#endif
+
+#define I2C_MINORS             256
+
+#define  CALIBRATION_FLAG      1
+
+static unsigned char status_reg = 0;
+static struct workqueue_struct *pixcir_wq;
+static struct pixcir_i2c_ts_data *this_data;
+
+struct point_data{
+       unsigned char   brn;  //broken line number
+       unsigned char   brn_pre;
+       unsigned char   id;    //finger ID
+       int     posx;
+       int     posy;
+};
+
+static struct point_data point[MAX_SUPPORT_POINT];
+
+
+struct i2c_dev
+{
+       struct list_head list;
+       struct i2c_adapter *adap;
+       struct device *dev;
+};
+
+static struct i2c_driver pixcir_i2c_ts_driver;
+static struct class *i2c_dev_class;
+static LIST_HEAD( i2c_dev_list);
+static DEFINE_SPINLOCK( i2c_dev_list_lock);
+
+static void return_i2c_dev(struct i2c_dev *i2c_dev)
+{
+       spin_lock(&i2c_dev_list_lock);
+       list_del(&i2c_dev->list);
+       spin_unlock(&i2c_dev_list_lock);
+       kfree(i2c_dev);
+}
+
+static struct i2c_dev *i2c_dev_get_by_minor(unsigned index)
+{
+       struct i2c_dev *i2c_dev;
+       i2c_dev = NULL;
+
+       spin_lock(&i2c_dev_list_lock);
+       list_for_each_entry(i2c_dev, &i2c_dev_list, list)
+       {
+               if (i2c_dev->adap->nr == index)
+                       goto found;
+       }
+       i2c_dev = NULL;
+       found: spin_unlock(&i2c_dev_list_lock);
+       return i2c_dev;
+}
+
+static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap)
+{
+       struct i2c_dev *i2c_dev;
+
+       if (adap->nr >= I2C_MINORS) {
+               printk(KERN_ERR "i2c-dev: Out of device minors (%d)\n",
+                               adap->nr);
+               return ERR_PTR(-ENODEV);
+       }
+
+       i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL);
+       if (!i2c_dev)
+               return ERR_PTR(-ENOMEM);
+
+       i2c_dev->adap = adap;
+
+       spin_lock(&i2c_dev_list_lock);
+       list_add_tail(&i2c_dev->list, &i2c_dev_list);
+       spin_unlock(&i2c_dev_list_lock);
+       return i2c_dev;
+}
+/*********************************Bee-0928-bottom**************************************/
+
+struct pixcir_i2c_ts_data {
+       struct i2c_client *client;
+       struct input_dev *input,*input_key_dev;
+       int use_irq;
+       int     gpio_pendown;
+       int     gpio_reset;
+       int     gpio_reset_active_low;
+       int             pendown_iomux_mode;     
+       int             resetpin_iomux_mode;
+       char    pendown_iomux_name[IOMUX_NAME_SIZE];    
+       char    resetpin_iomux_name[IOMUX_NAME_SIZE];           
+       struct  work_struct  work;
+       //const struct pixcir_ts_platform_data *chip;
+       bool exiting;
+    struct     early_suspend early_suspend;
+};
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void pixcir_ts_early_suspend(struct early_suspend *h);
+static void pixcir_ts_late_resume(struct early_suspend *h);
+#endif
+
+int tp_pixcir_write_reg(struct i2c_client *client,const char *buf ,int count)
+{
+  struct i2c_msg msg[] = {
+    {
+      .addr  = client->addr,
+      .flags = 0,
+      .len   = count,
+      .buf   = (char *)buf,
+    }
+  };
+  
+       //ret = i2c_transfer(adap, &msg, 1);
+       if (i2c_transfer(client->adapter, msg, 1) < 0)
+       {
+               printk("write the address (0x%x) of the ssd2533 fail.",buf[0]);
+               return -1;
+       }
+       return 0;
+}
+
+int tp_pixcir_read_reg(struct i2c_client *client,u8 addr,u8 *buf,u8 len)
+{
+       u8 msgbuf[1] = { addr };
+       struct i2c_msg msgs[] = {
+               {
+                       .addr    = client->addr,
+                       .flags = 0, //Write
+                       .len     = 1,
+                       .buf     = msgbuf,
+               },
+               {
+                       .addr    = client->addr,
+                       .flags = I2C_M_RD,
+                       .len     = len,
+                       .buf     = buf,
+               },
+       };
+       if (i2c_transfer(client->adapter, msgs, 2) < 0)
+       {
+               printk("read the address (0x%x) of the ssd2533 fail.",addr);
+               return -1;
+       }
+       return 0;
+}
+
+static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
+{
+       struct pixcir_i2c_ts_data *tsdata = data;
+       
+       u8 *p;
+       u8 touch, button;
+       u8 rdbuf[27], wrbuf[1] = { 0 };
+       int ret, i;
+       int ignore_cnt = 0;
+       
+       ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf));
+       if (ret != sizeof(wrbuf)) {
+               dev_err(&tsdata->client->dev,
+                       "%s: i2c_master_send failed(), ret=%d\n",
+                       __func__, ret);
+               return;
+       }
+
+       ret = i2c_master_recv(tsdata->client, rdbuf, sizeof(rdbuf));
+       if (ret != sizeof(rdbuf)) {
+               dev_err(&tsdata->client->dev,
+                       "%s: i2c_master_recv failed(), ret=%d\n",
+                       __func__, ret);
+               return;
+       }
+       
+       touch = rdbuf[0] & 0x07;
+       button = rdbuf[1];
+       p = &rdbuf[2];
+       for (i = 0; i < touch; i++)     {
+               point[i].brn = (*(p + 4)) >> 3;         
+               point[i].id = (*(p + 4)) & 0x7; 
+               point[i].posx = (*(p + 1) << 8) + (*(p));       
+               point[i].posy = (*(p + 3) << 8) + (*(p + 2));
+               p+=5;
+       }
+
+       if (touch) {
+               for(i=0; i < touch; i++) {
+                       if (point[i].posy < 40 || point[i].posy > 520 || point[i].posx < 40) {
+                               ignore_cnt++;  //invalid point
+                               continue;
+                       }else {
+                               point[i].posy -= 40;
+                               point[i].posx -= 40;
+
+                               if(point[i].posy < 0)
+                                       point[i].posy=1;
+
+                               if(point[i].posx < 0)
+                                       point[i].posx=1;
+
+                               input_mt_slot(tsdata->input, 0);
+                               input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, true);
+                               input_report_abs(tsdata->input, ABS_MT_TOUCH_MAJOR, 1);
+                               input_report_abs(tsdata->input, ABS_MT_POSITION_X, point[i].posy);
+                               input_report_abs(tsdata->input, ABS_MT_POSITION_Y, point[i].posx);
+
+                               //input_sync(tsdata->input);
+
+                               DBG("brn%d=%2d id%d=%1d x=%5d y=%5d \n",
+                                       i,point[i].brn,i,point[i].id,point[i].posy,point[i].posx);
+                       }                       
+               }              
+
+               if (touch == ignore_cnt)
+                       return; //if all touchpoint are invalid, return
+
+               input_sync(tsdata->input);
+       } 
+}
+
+static void pixcir_ts_work_func(struct work_struct *work)
+{
+       struct pixcir_i2c_ts_data *tsdata = this_data;
+       //DBG("%s\n",__FUNCTION__);
+
+       while (!tsdata->exiting) {
+       
+               pixcir_ts_poscheck(tsdata);
+
+               if (attb_read_val()){
+                       DBG("%s:  >>>>>touch release\n\n",__FUNCTION__);
+                       enable_irq(tsdata->client->irq);
+                       //input_report_key(tsdata->input, BTN_TOUCH, 0);
+                       //input_report_abs(tsdata->input, ABS_MT_TOUCH_MAJOR, 0);
+                       input_mt_slot(tsdata->input, 0);
+                       input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, false);
+                       //input_report_key(tsdata->input, ABS_MT_WIDTH_MAJOR,0);
+                       break;
+               }
+
+               msleep(1);
+       }
+
+       input_sync(tsdata->input);
+       return;
+}
+
+static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
+{
+    struct pixcir_i2c_ts_data *ts = dev_id;
+    DBG("%s: >>>>>>>>>\n",__FUNCTION__);
+       
+       if(ts->use_irq){
+       disable_irq_nosync(ts->client->irq);
+       }
+       queue_work(pixcir_wq, &ts->work);
+
+    return IRQ_HANDLED;
+}
+
+#if 0
+#ifdef CONFIG_PM_SLEEP
+static int pixcir_i2c_ts_suspend(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       pixcir_dbg("%s\n",__FUNCTION__);
+
+       if (device_may_wakeup(&client->dev))
+               enable_irq_wake(client->irq);
+
+       return 0;
+}
+
+static int pixcir_i2c_ts_resume(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       pixcir_dbg("%s\n",__FUNCTION__);
+
+       if (device_may_wakeup(&client->dev))
+               disable_irq_wake(client->irq);
+
+       return 0;
+}
+#endif
+static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
+                        pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume);
+
+static int __devinit setup_resetPin(struct i2c_client *client, struct pixcir_i2c_ts_data *ts)
+{
+       struct pixcir_platform_data     *pdata = client->dev.platform_data;
+       int err;
+       
+       pixcir_dbg("%s\n",__FUNCTION__);
+
+       
+       ts->gpio_reset = pdata->gpio_reset;
+    ts->gpio_reset_active_low = pdata->gpio_reset_active_low;
+    ts->resetpin_iomux_mode = pdata->resetpin_iomux_mode;
+       ///*
+
+    if(pdata->resetpin_iomux_name != NULL)
+           strcpy(ts->resetpin_iomux_name,pdata->resetpin_iomux_name);
+       
+       //pixcir_dbg("%s=%d,%s,%d,%d\n",__FUNCTION__,ts->gpio_reset,ts->resetpin_iomux_name,ts->resetpin_iomux_mode,ts->gpio_reset_active_low);
+       if (!gpio_is_valid(ts->gpio_reset)) {
+               dev_err(&client->dev, "no gpio_reset?\n");
+               return -EINVAL;
+       }
+
+    rk29_mux_api_set(ts->resetpin_iomux_name,ts->resetpin_iomux_mode); 
+       //*/
+
+       err = gpio_request(ts->gpio_reset, "pixcir_resetPin");
+       if (err) {
+               dev_err(&client->dev, "failed to request resetPin GPIO%d\n",
+                               ts->gpio_reset);
+               return err;
+       }
+       
+       err = gpio_direction_output(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_LOW:GPIO_HIGH);
+       if (err) {
+               dev_err(&client->dev, "failed to pulldown resetPin GPIO%d,err%d\n",
+                               ts->gpio_reset,err);
+               gpio_free(ts->gpio_reset);
+               return err;
+       }
+       mdelay(100);
+       gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_HIGH:GPIO_LOW);
+       mdelay(100);
+
+       return 0;
+}
+
+static int __devinit setup_pendown(struct i2c_client *client, struct pixcir_i2c_ts_data *ts)
+{
+       int err;
+       struct pixcir_i2c_ts_data       *pdata = client->dev.platform_data;
+
+       pixcir_dbg("%s\n",__FUNCTION__);
+       if (!client->irq) {
+               dev_dbg(&client->dev, "no IRQ?\n");
+               return -ENODEV;
+       }
+       
+       if (!gpio_is_valid(pdata->gpio_pendown)) {
+               dev_err(&client->dev, "no gpio_pendown?\n");
+               return -EINVAL;
+       }
+       
+       ts->gpio_pendown = pdata->gpio_pendown;
+       strcpy(ts->pendown_iomux_name,pdata->pendown_iomux_name);
+       ts->pendown_iomux_mode = pdata->pendown_iomux_mode;
+       
+       pixcir_dbg("%s=%d,%s,%d\n",__FUNCTION__,ts->gpio_pendown,ts->pendown_iomux_name,ts->pendown_iomux_mode);
+       
+       if (!gpio_is_valid(ts->gpio_pendown)) {
+               dev_err(&client->dev, "no gpio_pendown?\n");
+               return -EINVAL;
+       }
+       
+    rk29_mux_api_set(ts->pendown_iomux_name,ts->pendown_iomux_mode); 
+       err = gpio_request(ts->gpio_pendown, "gt801_pendown");
+       if (err) {
+               dev_err(&client->dev, "failed to request pendown GPIO%d\n",
+                               ts->gpio_pendown);
+               return err;
+       }
+       
+       err = gpio_pull_updown(ts->gpio_pendown, GPIOPullUp);
+       if (err) {
+               dev_err(&client->dev, "failed to pullup pendown GPIO%d\n",
+                               ts->gpio_pendown);
+               gpio_free(ts->gpio_pendown);
+               return err;
+       }
+       return 0;
+}
+#endif
+
+static ssize_t pixcir_proc_write(struct file *file, const char __user *buffer,
+                          size_t count, loff_t *data)
+{
+       char c;
+       int rc;
+       
+       rc = get_user(c, buffer);
+       if (rc)
+               return rc; 
+       
+       if (c == '1')
+               ts_dbg_enable = 1; 
+       else if (c == '0')
+               ts_dbg_enable = 0; 
+
+       return count; 
+}
+
+static const struct file_operations pixcir_proc_fops = {
+       .owner          = THIS_MODULE, 
+       .write          = pixcir_proc_write,
+}; 
+static int __devinit pixcir_i2c_ts_probe(struct i2c_client *client,
+                                        const struct i2c_device_id *id)
+{
+       //const struct pixcir_ts_platform_data *pdata = client->dev.platform_data;
+       struct pixcir_i2c_ts_data *tsdata;
+       struct pixcir_platform_data *pdata;
+       struct device *dev;
+       struct i2c_dev *i2c_dev;
+       int error = 0;
+       struct proc_dir_entry *pixcir_proc_entry;       
+
+       //if (!pdata) {
+       //      dev_err(&client->dev, "platform data not defined\n");
+       //      return -EINVAL;
+       //}
+       pixcir_dbg("%s\n",__FUNCTION__);
+
+       tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL);
+       tsdata->input = input_allocate_device();
+       if (!tsdata || !(tsdata->input)) {
+               dev_err(&client->dev, "Failed to allocate driver data!\n");
+               error = -ENOMEM;
+               goto err_free_mem;
+       }
+       
+       pixcir_wq = create_singlethread_workqueue("pixcir_tp_wq");
+       if (!pixcir_wq) {
+               printk(KERN_ERR"%s: create workqueue failed\n", __FUNCTION__);
+               error = -ENOMEM;
+               goto err_free_mem;
+       }
+       INIT_WORK(&tsdata->work, pixcir_ts_work_func);
+       
+       this_data = tsdata;
+       tsdata->exiting = false;
+       //tsdata->input = input;
+       //tsdata->chip = pdata;
+       
+       tsdata->client = client;
+       i2c_set_clientdata(client, tsdata);
+       pdata = client->dev.platform_data;
+
+       //error = setup_resetPin(client,tsdata);
+       if(error)
+       {
+                printk("%s:setup_resetPin fail\n",__FUNCTION__);
+                goto err_free_mem;
+       }
+       tsdata->input->phys = "/dev/input/event2";
+       tsdata->input->name = "pixcir_ts-touchscreen";//client->name;
+       tsdata->input->id.bustype = BUS_I2C;
+       tsdata->input->dev.parent = &client->dev;
+       
+       
+       ///*
+       /*set_bit(EV_SYN,    tsdata->input->evbit);
+       set_bit(EV_KEY,    tsdata->input->evbit);
+       set_bit(EV_ABS,    tsdata->input->evbit);
+       set_bit(BTN_TOUCH, tsdata->input->keybit);
+       set_bit(BTN_2,     tsdata->input->keybit);//*/
+       
+       //tsdata->input->evbit[0] = BIT_MASK(EV_SYN) |  BIT_MASK(EV_ABS) ;
+       //tsdata->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+       /*tsdata->input->absbit[0] = BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y) |
+                       BIT_MASK(ABS_MT_TOUCH_MAJOR) | BIT_MASK(ABS_MT_WIDTH_MAJOR);  // for android*/
+       //tsdata->input->keybit[BIT_WORD(BTN_START)] = BIT_MASK(BTN_START);
+
+       //input_set_abs_params(input, ABS_X, 0, X_MAX, 0, 0);
+       //input_set_abs_params(input, ABS_Y, 0, Y_MAX, 0, 0);
+
+       __set_bit(INPUT_PROP_DIRECT, tsdata->input->propbit);
+       __set_bit(EV_ABS, tsdata->input->evbit);
+
+       input_mt_init_slots(tsdata->input, MAX_SUPPORT_POINT);
+       input_set_abs_params(tsdata->input, ABS_MT_POSITION_X,  pdata->x_min,  pdata->x_max, 0, 0);
+       input_set_abs_params(tsdata->input, ABS_MT_POSITION_Y,  pdata->y_min, pdata->y_max, 0, 0);
+       //input_set_abs_params(tsdata->input, ABS_MT_WIDTH_MAJOR, 0,   16, 0, 0);
+       //input_set_abs_params(tsdata->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
+       input_set_abs_params(tsdata->input, ABS_MT_TOUCH_MAJOR, 0,    1, 0, 0);
+       //input_set_abs_params(tsdata->input, ABS_MT_TRACKING_ID, 0,    5, 0, 0);
+       input_set_drvdata(tsdata->input, tsdata);
+       //init int and reset ports
+       error = gpio_request(client->irq, "TS_INT");    //Request IO
+       if (error){
+               dev_err(&client->dev, "Failed to request GPIO:%d, ERRNO:%d\n",(int)client->irq, error);
+               goto err_free_mem;
+       }
+       rk29_mux_api_set(pdata->pendown_iomux_name, pdata->pendown_iomux_mode);
+       
+       gpio_direction_input(client->irq);
+       gpio_set_value(client->irq,GPIO_HIGH);
+       gpio_pull_updown(client->irq, 0);
+
+       error = gpio_request(pdata->gpio_reset, "pixcir_resetPin");
+       if(error){
+               dev_err(&client->dev, "failed to request resetPin GPIO%d\n", pdata->gpio_reset);
+               goto err_free_mem;
+       }
+       rk29_mux_api_set(pdata->resetpin_iomux_name, pdata->resetpin_iomux_mode);
+       /*{
+               gpio_pull_updown(pdata->gpio_reset, 1);
+               gpio_direction_output(pdata->gpio_reset, 0);
+               msleep(20);     //delay at least 1ms
+               gpio_direction_input(pdata->gpio_reset);
+               gpio_pull_updown(pdata->gpio_reset, 0);
+               msleep(120);
+       }*/
+    gpio_pull_updown(pdata->gpio_reset, 1);
+    mdelay(20);
+    gpio_direction_output(pdata->gpio_reset, 0);
+    gpio_set_value(pdata->gpio_reset,GPIO_HIGH);//GPIO_LOW
+    mdelay(100);
+    gpio_set_value(pdata->gpio_reset,GPIO_LOW);//GPIO_HIGH
+    mdelay(120);
+    // gpio_direction_input(pdata->gpio_reset);
+       printk("pdata->gpio_reset = %d\n",gpio_get_value(pdata->gpio_reset));
+    //printk("ts->gpio_irq = %d\n",gpio_get_value(pdata->gpio_pendown));
+       printk("pdata->gpio_pendown = %d\n",gpio_get_value(client->irq));
+
+#if 0
+       //**********************************************
+   char buffer[2];
+       buffer[0] = 0x3A;
+       buffer[1] = 0x03;
+       tp_pixcir_write_reg(client,buffer,2);
+       ssleep(6);
+       //********************************************************//
+#endif
+       client->irq = gpio_to_irq(client->irq); 
+       error = request_irq(client->irq, pixcir_ts_isr, IRQF_TRIGGER_FALLING, client->name, (void *)tsdata);
+       if (error)
+               dev_err(&client->dev, "request_irq failed\n");
+/*
+       error = request_threaded_irq(client->irq, NULL, pixcir_ts_isr,
+                                    IRQF_TRIGGER_FALLING,
+                                    client->name, tsdata);*/
+       tsdata->use_irq = 1;
+       if (error) {
+               dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
+               tsdata->use_irq = 0;
+               goto err_free_mem;
+       }
+
+       error = input_register_device(tsdata->input);
+       if (error)
+               goto err_free_irq;
+
+       i2c_set_clientdata(client, tsdata);
+       device_init_wakeup(&client->dev, 1);
+
+       /*********************************Bee-0928-TOP****************************************/
+       i2c_dev = get_free_i2c_dev(client->adapter);
+       if (IS_ERR(i2c_dev)) {
+               error = PTR_ERR(i2c_dev);
+               return error;
+       }
+
+       dev = device_create(i2c_dev_class, &client->adapter->dev, MKDEV(I2C_MAJOR,
+                       client->adapter->nr), NULL, "pixcir_i2c_ts%d", 0);
+       if (IS_ERR(dev)) {
+               error = PTR_ERR(dev);
+               return error;
+       }
+       /*********************************Bee-0928-BOTTOM****************************************/
+#ifdef CONFIG_HAS_EARLYSUSPEND
+    tsdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+    tsdata->early_suspend.suspend = pixcir_ts_early_suspend;
+    tsdata->early_suspend.resume = pixcir_ts_late_resume;
+    register_early_suspend(&tsdata->early_suspend);
+#endif
+       pixcir_proc_entry = proc_create("driver/pixcir", 0777, NULL, &pixcir_proc_fops); 
+
+       dev_err(&tsdata->client->dev, "insmod successfully!\n");
+
+       return 0;
+
+err_free_irq:
+       free_irq(client->irq, tsdata);
+err_free_mem:
+       input_free_device(tsdata->input);
+       kfree(tsdata);
+       return error;
+}
+
+static int __devexit pixcir_i2c_ts_remove(struct i2c_client *client)
+{
+       int error;
+       struct i2c_dev *i2c_dev;
+       struct pixcir_i2c_ts_data *tsdata = i2c_get_clientdata(client);
+
+    unregister_early_suspend(&tsdata->early_suspend);
+       device_init_wakeup(&client->dev, 0);
+
+       tsdata->exiting = true;
+       mb();
+       free_irq(client->irq, tsdata);
+
+       /*********************************Bee-0928-TOP****************************************/
+       i2c_dev = get_free_i2c_dev(client->adapter);
+       if (IS_ERR(i2c_dev)) {
+               error = PTR_ERR(i2c_dev);
+               return error;
+       }
+
+       return_i2c_dev(i2c_dev);
+       device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, client->adapter->nr));
+       /*********************************Bee-0928-BOTTOM****************************************/
+
+       input_unregister_device(tsdata->input);
+       kfree(tsdata);
+
+       return 0;
+}
+
+/*************************************Bee-0928****************************************/
+/*                                  pixcir_open                                     */
+/*************************************Bee-0928****************************************/
+static int pixcir_open(struct inode *inode, struct file *file)
+{
+       int subminor;
+       struct i2c_client *client;
+       struct i2c_adapter *adapter;
+       struct i2c_dev *i2c_dev;
+       int ret = 0;
+#if PIXCIR_DEBUG
+       printk("enter pixcir_open function\n");
+#endif
+       subminor = iminor(inode);
+
+       //lock_kernel();
+       i2c_dev = i2c_dev_get_by_minor(subminor);
+       if (!i2c_dev) {
+               printk("error i2c_dev\n");
+               return -ENODEV;
+       }
+
+       adapter = i2c_get_adapter(i2c_dev->adap->nr);
+       if (!adapter) {
+               return -ENODEV;
+       }
+       
+       client = kzalloc(sizeof(*client), GFP_KERNEL);
+       if (!client) {
+               i2c_put_adapter(adapter);
+               ret = -ENOMEM;
+       }
+
+       snprintf(client->name, I2C_NAME_SIZE, "pixcir_i2c_ts%d", adapter->nr);
+       client->driver = &pixcir_i2c_ts_driver;
+       client->adapter = adapter;
+       
+       file->private_data = client;
+
+       return 0;
+}
+
+/*************************************Bee-0928****************************************/
+/*                                  pixcir_ioctl                                    */
+/*************************************Bee-0928****************************************/
+static long pixcir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       //printk("ioctl function\n");
+       struct i2c_client *client = (struct i2c_client *) file->private_data;
+#if PIXCIR_DEBUG
+       printk("cmd = %d,arg = %d\n", cmd, arg);
+#endif
+
+       switch (cmd)
+       {
+       case CALIBRATION_FLAG: //CALIBRATION_FLAG = 1
+#if PIXCIR_DEBUG
+               printk("CALIBRATION\n");
+#endif
+               client->addr = SLAVE_ADDR;
+               status_reg = 0;
+               status_reg = CALIBRATION_FLAG;
+               break;
+
+       default:
+               break;//return -ENOTTY;
+       }
+       return 0;
+}
+
+
+/***********************************Bee-0928****************************************/
+/*                               pixcir_write                                     */
+/***********************************Bee-0928****************************************/
+static ssize_t pixcir_write(struct file *file,const char __user *buf,size_t count, loff_t *ppos)
+{
+       struct i2c_client *client;
+       char *tmp;
+       static int ret=0;
+       
+       pixcir_dbg("%s\n",__FUNCTION__);
+
+       client = file->private_data;
+
+       //printk("pixcir_write function\n");
+       switch(status_reg)
+       {
+               case CALIBRATION_FLAG: //CALIBRATION_FLAG=1
+               tmp = kmalloc(count,GFP_KERNEL);
+               if (tmp==NULL)
+                       return -ENOMEM;
+
+               if (copy_from_user(tmp,buf,count)) {    
+                       printk("CALIBRATION_FLAG copy_from_user error\n");
+                       kfree(tmp);
+                       return -EFAULT;
+               }
+
+               ret = i2c_master_send(client,tmp,count);
+               if (ret!=count ) {
+                       dev_err(&client->dev,
+                               "%s: i2c_master_recv failed(), ret=%d\n",
+                               __func__, ret);
+               }
+
+               while(!attb_read_val());//waiting to finish the calibration.(pixcir application_note_710_v3 p43)
+
+               kfree(tmp);
+
+               status_reg = 0;
+               break;
+
+               default:
+               break;
+       }
+       return ret;
+}
+
+/***********************************Bee-0928****************************************/
+/*                               pixcir_release                                   */
+/***********************************Bee-0928****************************************/
+static int pixcir_release(struct inode *inode, struct file *file)
+{
+       struct i2c_client *client = file->private_data;
+   #if PIXCIR_DEBUG
+       printk("enter pixcir_release funtion\n");
+   #endif
+       i2c_put_adapter(client->adapter);
+       kfree(client);
+       file->private_data = NULL;
+
+       return 0;
+}
+
+/*********************************Bee-0928-TOP****************************************/
+static const struct file_operations pixcir_i2c_ts_fops =
+{      .owner          = THIS_MODULE,
+       .write          = pixcir_write,
+       .open           = pixcir_open,
+       .unlocked_ioctl = pixcir_ioctl,
+       .release        = pixcir_release,
+};
+/*********************************Bee-0928-BOTTOM****************************************/
+
+static int pixcir_ts_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+    struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
+       DBG("%s\n",__FUNCTION__);
+
+       if (ts->use_irq)
+               disable_irq(client->irq);
+       //gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_LOW:GPIO_HIGH);
+       return 0;
+}
+
+static int pixcir_ts_resume(struct i2c_client *client)
+{
+    struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
+       DBG("%s\n",__FUNCTION__);
+
+       if (ts->use_irq)
+               enable_irq(client->irq);
+    //gpio_set_value(ts->gpio_reset, ts->gpio_reset_active_low? GPIO_HIGH:GPIO_LOW);
+       return 0;
+}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void pixcir_ts_early_suspend(struct early_suspend *h)
+{
+    struct pixcir_i2c_ts_data *ts;
+       DBG("%s\n",__FUNCTION__);
+    ts = container_of(h, struct pixcir_i2c_ts_data, early_suspend);
+    pixcir_ts_suspend(ts->client, PMSG_SUSPEND);
+}
+
+static void pixcir_ts_late_resume(struct early_suspend *h)
+{
+    struct pixcir_i2c_ts_data *ts;
+       DBG("%s\n",__FUNCTION__);
+    ts = container_of(h, struct pixcir_i2c_ts_data, early_suspend);
+    pixcir_ts_resume(ts->client);
+}
+#endif
+
+static const struct i2c_device_id pixcir_i2c_ts_id[] = {
+       { "pixcir_ts", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id);
+
+static struct i2c_driver pixcir_i2c_ts_driver = {
+       .driver = {
+               .owner  = THIS_MODULE,
+               .name   = "pixcir_ts",
+               //.pm   = &pixcir_dev_pm_ops,
+       },
+#ifndef CONFIG_HAS_EARLYSUSPEND
+    .suspend    = pixcir_ts_suspend,
+    .resume     = pixcir_ts_resume,
+#endif
+       .probe          = pixcir_i2c_ts_probe,
+       .remove         = __devexit_p(pixcir_i2c_ts_remove),
+       .id_table       = pixcir_i2c_ts_id,
+};
+
+static int __init pixcir_i2c_ts_init(void)
+{
+       int ret;
+
+       pixcir_dbg("%s\n",__FUNCTION__);
+       
+    pixcir_wq = create_singlethread_workqueue("pixcir_wq");
+    if (!pixcir_wq)
+        return -ENOMEM;
+
+       /*********************************Bee-0928-TOP****************************************/
+       ret = register_chrdev(I2C_MAJOR,"pixcir_i2c_ts",&pixcir_i2c_ts_fops);
+       if (ret) {
+               printk(KERN_ERR "%s:register chrdev failed\n",__FILE__);
+               return ret;
+       }
+
+       i2c_dev_class = class_create(THIS_MODULE, "pixcir_i2c_dev");
+       if (IS_ERR(i2c_dev_class)) {
+               ret = PTR_ERR(i2c_dev_class);
+               class_destroy(i2c_dev_class);
+       }
+       /********************************Bee-0928-BOTTOM******************************************/
+
+       //tangoC_init();
+
+       return i2c_add_driver(&pixcir_i2c_ts_driver);
+}
+module_init(pixcir_i2c_ts_init);
+
+static void __exit pixcir_i2c_ts_exit(void)
+{
+       i2c_del_driver(&pixcir_i2c_ts_driver);
+    if (pixcir_wq)
+        destroy_workqueue(pixcir_wq);
+       /********************************Bee-0928-TOP******************************************/
+       class_destroy(i2c_dev_class);
+       unregister_chrdev(I2C_MAJOR,"pixcir_i2c_ts");
+       /********************************Bee-0928-BOTTOM******************************************/
+}
+module_exit(pixcir_i2c_ts_exit);
+
+MODULE_AUTHOR("Jianchun Bian <jcbian@pixcir.com.cn>");
+MODULE_DESCRIPTION("Pixcir I2C Touchscreen Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.h b/drivers/input/touchscreen/pixcir_i2c_ts.h
new file mode 100644 (file)
index 0000000..e19773e
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef __DRIVERS_TOUCHSCREEN_PIXCIR_TS_H\r
+#define __DRIVERS_TOUCHSCREEN_PIXCIR_TS_H\r
+\r
+// #include <mach/gpio.h>\r
+\r
+static int attb_read_val(void);\r
+static void tangoC_init(void);\r
+\r
+#define X_MAX 480\r
+#define Y_MAX 800\r
+#define MAX_SUPPORT_POINT 5
+\r
+#define IOMUX_NAME_SIZE 48\r
+struct pixcir_platform_data {\r
+\r
+       u16             model;                  /*. */\r
+       bool    swap_xy;                /* swap x and y axes */\r
+       u16             x_min, x_max;\r
+       u16             y_min, y_max;\r
+    int        gpio_reset;\r
+    int     gpio_reset_active_low;\r
+       int             gpio_pendown;           /* the GPIO used to decide the pendown */\r
+\r
+       char    pendown_iomux_name[IOMUX_NAME_SIZE];\r
+       char    resetpin_iomux_name[IOMUX_NAME_SIZE];\r
+       int             pendown_iomux_mode;\r
+       int             resetpin_iomux_mode;\r
+       \r
+       uint8_t                     virtual_key_num;\r
+       uint16_t                   virtual_key_code[4];\r
+\r
+       int         (*get_pendown_state)(void);\r
+};\r
+\r
+//Platform gpio define\r
+//#define      S5PC1XX\r
+\r
+#ifdef S5PC1XX\r
+       #include <plat/gpio-bank-e1.h> //reset pin GPE1_5\r
+       #include <plat/gpio-bank-h1.h> //attb pin GPH1_3\r
+       #include <mach/gpio.h>\r
+       #include <plat/gpio-cfg.h>\r
+\r
+       #define ATTB            S5PC1XX_GPH1(3)\r
+       #define get_attb_value  gpio_get_value\r
+       #define RESETPIN_CFG    s3c_gpio_cfgpin(S5PC1XX_GPE1(5),S3C_GPIO_OUTPUT)\r
+       #define RESETPIN_SET0   gpio_direction_output(S5PC1XX_GPE1(5),0)\r
+       #define RESETPIN_SET1   gpio_direction_output(S5PC1XX_GPE1(5),1)\r
+\r
+#else  //mini6410\r
+\r
+//     #include <plat/gpio-cfg.h>\r
+//     #include <mach/gpio-bank-e.h>\r
+//     #include <mach/gpio-bank-n.h>\r
+//     #include <mach/gpio.h>\r
+\r
+       #define ATTB            RK29_PIN4_PD5\r
+       #define get_attb_value  gpio_get_value\r
+       #define RESETPIN_CFG    //s3c_gpio_cfgpin(RK29_PIN4_PD5,S3C_GPIO_OUTPUT)\r
+       //rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);\r
+       #define RESETPIN_SET0   gpio_direction_output(RK29_PIN4_PD5,0)\r
+       #define RESETPIN_SET1   gpio_direction_output(RK29_PIN4_PD5,1)\r
+#endif\r
+\r
+static int attb_read_val(void)\r
+{\r
+       return gpio_get_value(RK29_PIN4_PD5);\r
+}\r
+\r
+/*static void tangoC_init(void)\r
+{\r
+       RESETPIN_SET0;\r
+}*/\r
+#endif\r
index 6c458ae808a717a0fbb3d7d5a012537a2ed45cab..7ef21f43d2d3ed7b8e2658f3ad61d0afb5a49827 100755 (executable)
@@ -1447,7 +1447,7 @@ sensor_power_end:
 }
 static int sensor_init(struct v4l2_subdev *sd, u32 val)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
        const struct v4l2_queryctrl *qctrl;
@@ -1643,7 +1643,7 @@ static unsigned long sensor_query_bus_param(struct soc_camera_device *icd)
 
 static int sensor_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
 
@@ -1692,7 +1692,7 @@ static bool sensor_fmt_videochk(struct v4l2_subdev *sd, struct v4l2_mbus_framefm
 }
 static int sensor_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     const struct sensor_datafmt *fmt;
     struct sensor *sensor = to_sensor(client);
        const struct v4l2_queryctrl *qctrl;
@@ -1835,7 +1835,7 @@ sensor_s_fmt_end:
 
 static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct sensor_datafmt *fmt;
     int ret = 0;
@@ -1864,7 +1864,7 @@ static int sensor_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
 
  static int sensor_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *id)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
 
     if (id->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
         return -EINVAL;
@@ -2148,7 +2148,7 @@ static int sensor_set_flash(struct soc_camera_device *icd, const struct v4l2_que
 
 static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     const struct v4l2_queryctrl *qctrl;
 
@@ -2207,7 +2207,7 @@ static int sensor_g_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 
 static int sensor_s_control(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct sensor *sensor = to_sensor(client);
     struct soc_camera_device *icd = client->dev.platform_data;
     const struct v4l2_queryctrl *qctrl;
@@ -2497,7 +2497,7 @@ static int sensor_s_ext_control(struct soc_camera_device *icd, struct v4l2_ext_c
 
 static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct soc_camera_device *icd = client->dev.platform_data;
     int i, error_cnt=0, error_idx=-1;
 
@@ -2522,7 +2522,7 @@ static int sensor_g_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_control
 
 static int sensor_s_ext_controls(struct v4l2_subdev *sd, struct v4l2_ext_controls *ext_ctrl)
 {
-    struct i2c_client *client = sd->priv;
+    struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct soc_camera_device *icd = client->dev.platform_data;
     int i, error_cnt=0, error_idx=-1;
 
@@ -2599,7 +2599,7 @@ sensor_video_probe_err:
 }
 static long sensor_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
 {
-       struct i2c_client *client = sd->priv;
+       struct i2c_client *client = v4l2_get_subdevdata(sd);
     struct soc_camera_device *icd = client->dev.platform_data;
     struct sensor *sensor = to_sensor(client);
     int ret = 0;
index 3d109a52cd56976926f66a57fb502881167c760d..9c840dcf1f04615bada2300defad902d00ea8552 100755 (executable)
@@ -180,7 +180,8 @@ static int __init wm831x_i2c_init(void)
        return ret;
 }
 //subsys_initcall(wm831x_i2c_init);
-fs_initcall(wm831x_i2c_init);
+//fs_initcall(wm831x_i2c_init);
+subsys_initcall_sync(wm831x_i2c_init);
 static void __exit wm831x_i2c_exit(void)
 {
        i2c_del_driver(&wm831x_i2c_driver);
index e198d40292e7f5cb9c1ed5e78c4d3f41e30f1bc5..7ecd7de78c3366894660f09fe81e8a7e85fbfe86 100644 (file)
@@ -651,7 +651,7 @@ static UNIVERSAL_DEV_PM_OPS(wm8994_pm_ops, wm8994_suspend, wm8994_resume,
 
 static struct i2c_driver wm8994_i2c_driver = {
        .driver = {
-               .name = "wm8994",
+               .name = "WM8994",
                .owner = THIS_MODULE,
                .pm = &wm8994_pm_ops,
        },
index a9a94491b0284d9ddb847ac24b9e212a66c8f529..710153c51556985d22478dfc965f6b1eee287b39 100644 (file)
@@ -540,7 +540,8 @@ config STE
 
 config MTK23D
        bool "MTK6223D modem control driver"
-
+       default n       
+       
 config FM580X
        bool "FM rda580x driver"
 
@@ -553,6 +554,15 @@ config MW100
 config RK29_NEWTON
        bool "RK29_NEWTON misc driver"
 
+config RK29_SC8800
+       bool "SC8800 misc driver"
+       default n
+
+config TDSC8800
+       bool "TDSC8800 modem control driver"
+       default n
+       
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
index c4ed797a893bcfb486333c7146b5095d6e8a4bb5..3a67414ad02359a3fce9c5b408cb30bb365a9de1 100644 (file)
@@ -61,3 +61,5 @@ obj-$(CONFIG_RK29_SUPPORT_MODEM)      += rk29_modem/
 obj-$(CONFIG_GPS_GNS7560)      += gps/
 obj-y += mpu3050/
 obj-$(CONFIG_RK29_NEWTON)      += newton.o
+obj-$(CONFIG_TDSC8800) += tdsc8800.o
+obj-$(CONFIG_RK29_SC8800)      +=      sc8800.o
index a0fe107d3e46bb71410403a82f55202fa87cea43..8f8dae6233953a2afaa3b875b538688cd75e8f22 100755 (executable)
@@ -291,9 +291,9 @@ int modem_poweron_off(int on_off)
 static int power_on =1;
 static int mtk23d_open(struct inode *inode, struct file *file)
 {
-       struct rk2818_23d_data *pdata = gpdata;
+       //struct rk2818_23d_data *pdata = gpdata;
        //struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
-       struct platform_data *pdev = container_of(pdata, struct device, platform_data);
+       //struct platform_data *pdev = container_of(pdata, struct device, platform_data);
 
        MODEMDBG("modem_open\n");
 
@@ -303,7 +303,7 @@ static int mtk23d_open(struct inode *inode, struct file *file)
                power_on = 0;
                modem_poweron_off(1);
        }
-       device_init_wakeup(&pdev, 1);
+       device_init_wakeup(&pdev->dev, 1);
 
        return 0;
 }
@@ -424,6 +424,7 @@ static int mtk23d_probe(struct platform_device *pdev)
        MODEMDBG("mtk23d_probe\n");
 
        //pdata->io_init();
+       pdata->dev = &pdev->dev;
 
        mt6223d_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL);
        if(NULL == mt6223d_data)
diff --git a/drivers/misc/sc8800.c b/drivers/misc/sc8800.c
new file mode 100755 (executable)
index 0000000..c8d26fe
--- /dev/null
@@ -0,0 +1,728 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/spi/spi.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/miscdevice.h>
+#include <linux/wait.h>
+#include <linux/uaccess.h>
+#include <linux/fs.h>
+#include <linux/rwsem.h>
+#include <mach/gpio.h>
+#include <mach/iomux.h>
+#include <mach/board.h>
+#include <linux/wakelock.h>
+
+#if 0
+#define sc8800_dbg(dev, format, arg...)                \
+       dev_printk(KERN_INFO , dev , format , ## arg)
+//#define SC8800_PRINT_BUF
+#else
+#define sc8800_dbg(dev, format, arg...)
+#endif
+
+#define READ_TIMEOUT           30000  //no use
+#define WRITE_TIMEOUT          80  //80ms
+
+#define RD_BUF_SIZE                    (16*PAGE_SIZE) // 64K
+#define WR_BUF_SIZE                    (2*PAGE_SIZE) // __get_free_pages(GFP_KERNEL, 1) ==> pages = 2^1 = 2
+#define MAX_RX_LIST                    256
+
+#define BP_PACKET_SIZE         64
+#define BP_PACKET_HEAD_LEN  16
+#define BP_PACKET_DATA_LEN  48
+
+struct plat_sc8800 {
+       int slav_rts_pin;
+       int slav_rdy_pin;
+       int master_rts_pin;
+       int master_rdy_pin;
+       int poll_time;
+};
+struct bp_head{
+       u16 tag;        //0x7e7f
+       u16 type;       //0xaa55
+       u32 length;     //the length of data after head(8192-128 bytes) 
+       u32 fram_num;   //no used , always 0
+       u32 reserved;   ////reserved 
+       char data[BP_PACKET_DATA_LEN];
+};
+
+struct sc8800_data {
+       struct device                   *dev;
+       struct spi_device               *spi;
+       struct workqueue_struct *rx_wq;
+       struct workqueue_struct *tx_wq;
+       struct work_struct              rx_work;
+       struct work_struct              tx_work;
+       struct wake_lock        rx_wake;
+       struct wake_lock  tx_wake;
+
+       wait_queue_head_t               waitrq;
+       wait_queue_head_t               waitwq;
+       spinlock_t                              lock;
+
+       int irq;
+       int slav_rts;
+       int slav_rdy;
+       int master_rts;
+       int master_rdy;
+
+       int write_finished;
+       int write_tmo;
+
+       char *rx_buf;
+       int     rx_len; 
+
+       char *tx_buf;
+       int     tx_len; 
+
+       int rw_enable;
+
+       int is_suspend;
+};
+static DEFINE_MUTEX(sc8800s_lock);
+static DECLARE_RWSEM(sc8800_rsem);  
+static DECLARE_RWSEM(sc8800_wsem);  
+struct sc8800_data *g_sc8800 = NULL;
+
+char tmp_buf[1024];
+static int bp_rts(struct sc8800_data *sc8800)
+{
+       return gpio_get_value(sc8800->slav_rts);
+}
+
+static int bp_rdy(struct sc8800_data *sc8800)
+{
+       return gpio_get_value(sc8800->slav_rdy);
+}
+
+static void ap_rts(struct sc8800_data *sc8800, int value)
+{
+       gpio_set_value(sc8800->master_rts, value);
+}
+
+static void ap_rdy(struct sc8800_data *sc8800, int value)
+{
+       gpio_set_value(sc8800->master_rdy, value);
+}
+static void sc8800_print_buf(struct sc8800_data *sc8800, char *buf, const char *func, int len)
+{
+#ifdef SC8800_PRINT_BUF
+       int i;
+       char *tmp = NULL;
+       tmp = kzalloc(len*7, GFP_KERNEL);
+       sc8800_dbg(sc8800->dev, "%s buf[%d] = :\n", func, len);
+       for(i = 0; i < len; i++){
+               if(i % 16 == 0 && i != 0)
+                       sprintf(tmp, "%s\n", tmp);
+               sprintf(tmp, "%s[0x%2x] ", tmp, buf[i]);
+       }
+       printk("%s\n", tmp);
+       kfree(tmp);
+#endif
+       return;
+}
+static void buf_swp(char *buf, int len)
+{
+       int i;
+       char temp;
+               
+       len = (len/2)*2;
+       for(i = 0; i < len; i += 2)
+       {
+               temp = buf[i];
+               buf[i] = buf[i+1];
+               buf[i+1] = temp;
+       }
+}
+static void spi_in(struct sc8800_data *sc8800, char *tx_buf, unsigned len, int* err)
+{
+       struct spi_message message;
+       struct spi_transfer tran;
+
+       buf_swp(tx_buf, len);
+
+       tran.tx_buf = (void *)tx_buf;
+       tran.rx_buf = tmp_buf;
+       tran.len = len;
+       tran.speed_hz = 0;
+       tran.bits_per_word = 16;
+
+       spi_message_init(&message);
+       spi_message_add_tail(&tran, &message);
+       *err = spi_sync(sc8800->spi, &message);
+       sc8800_print_buf(sc8800, tx_buf, __func__, len);
+}
+
+static void spi_out(struct sc8800_data *sc8800, char *rx_buf, unsigned len, int* err)
+{
+       struct spi_message message;
+       struct spi_transfer tran;
+
+       memset(rx_buf, 0, len);
+       tran.tx_buf = tmp_buf;
+       tran.rx_buf = (void *)rx_buf;
+       tran.len = len;
+       tran.speed_hz = 0;
+       tran.bits_per_word = 16;
+
+       spi_message_init(&message);
+       spi_message_add_tail(&tran, &message);
+       *err = spi_sync(sc8800->spi, &message);
+       sc8800_print_buf(sc8800, rx_buf, __func__, len);
+
+       buf_swp(rx_buf, len);
+}
+
+static int ap_get_head(struct sc8800_data *sc8800, struct bp_head *packet)
+{
+       int err = 0, count = 5;
+       char buf[BP_PACKET_SIZE];
+
+retry:
+       spi_out(sc8800, buf, BP_PACKET_SIZE, &err);
+
+       if(err < 0 && count > 0)
+       {
+               dev_warn(sc8800->dev, "%s spi_out return error, retry count = %d\n",
+                               __func__, count);
+               count--;
+               mdelay(10);
+               goto retry;
+       }
+       if(err < 0)
+               return err;
+
+       memcpy((char *)(packet), buf, BP_PACKET_SIZE);
+
+       sc8800_dbg(sc8800->dev, "%s tag = 0x%4x, type = 0x%4x, length = %x\n",
+                       __func__, packet->tag, packet->type, packet->length);
+               
+       if ((packet->tag != 0x7e7f) || (packet->type != 0xaa55)) 
+               return -1;
+       else
+               return 0;
+}
+
+
+static int sc8800_rx(struct sc8800_data *sc8800)
+{
+       int ret = 0, len, real_len;
+       struct bp_head packet;
+       char *buf = NULL;
+
+       ap_rdy(sc8800,0);
+       ret = ap_get_head(sc8800, &packet);
+
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: %s ap_get_head err = %d\n", __func__, ret);
+               goto out;
+       }
+       len = packet.length;
+       if(len > BP_PACKET_DATA_LEN)
+               real_len =      (((len -BP_PACKET_DATA_LEN-1)/BP_PACKET_SIZE)+2)*BP_PACKET_SIZE;
+       else
+               real_len = BP_PACKET_SIZE;
+       if(len > RD_BUF_SIZE){
+               dev_err(sc8800->dev, "ERR: %s len[%d] is large than buffer size[%lu]\n",
+                               __func__, real_len, RD_BUF_SIZE);       
+               goto out;
+       }
+       buf = kzalloc(real_len, GFP_KERNEL);
+       if(!buf){
+               dev_err(sc8800->dev,"ERR: %s no memmory for rx_buf\n", __func__);
+               goto out;
+       }
+
+       memcpy(buf, packet.data, BP_PACKET_DATA_LEN);
+       if(len > BP_PACKET_DATA_LEN)
+               spi_out(sc8800, buf + BP_PACKET_DATA_LEN, real_len-BP_PACKET_SIZE, &ret);
+       
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: %s spi out err = %d\n", __func__, ret);
+               goto out;
+       }
+
+       spin_lock(&sc8800->lock);
+       if(sc8800->rx_len + len > RD_BUF_SIZE){
+               dev_warn(sc8800->dev, "WARN: %s read buffer is full\n", __func__);
+       }else
+       {
+               memcpy(sc8800->rx_buf+sc8800->rx_len, buf, len);
+               sc8800->rx_len += len;
+       }
+       spin_unlock(&sc8800->lock);
+
+       sc8800_dbg(sc8800->dev, "%s rx_len = %d\n", __func__, sc8800->rx_len);
+
+       ret = sc8800->rx_len;
+
+out:
+       ap_rdy(sc8800,1);
+       if(buf)
+               kfree(buf);
+       buf = NULL;
+       return ret;
+
+}
+ static int sc8800_data_packet(char *dst, char *src, int src_len)
+{
+       int dst_len = 0;
+       struct bp_head packet;
+
+       if(src_len > BP_PACKET_DATA_LEN)
+               dst_len = (((src_len -BP_PACKET_DATA_LEN-1)/BP_PACKET_SIZE)+2)*BP_PACKET_SIZE;
+       else
+               dst_len = BP_PACKET_SIZE;
+       
+       packet.tag =0x7e7f;
+       packet.type = 0xaa55;
+       packet.length = src_len;
+       packet.fram_num = 0;
+       packet.reserved = 0;
+       
+       memcpy(packet.data, src, BP_PACKET_DATA_LEN);   
+       memcpy(dst, (char *)&packet, BP_PACKET_SIZE);
+       if(src_len >= BP_PACKET_DATA_LEN)
+               memcpy(dst+BP_PACKET_SIZE, src+BP_PACKET_DATA_LEN, src_len - BP_PACKET_DATA_LEN);
+
+       return dst_len;
+ }
+
+static int sc8800_tx(struct sc8800_data *sc8800)
+{
+       int ret = 0, len;
+
+       char *buf = NULL;
+
+       sc8800->write_tmo = 0;
+       buf = kzalloc(WR_BUF_SIZE + BP_PACKET_SIZE, GFP_KERNEL);
+       if(!buf){
+               dev_err(sc8800->dev, "ERR: no memery for buf\n");
+               return -ENOMEM;
+       }
+       while(!bp_rts(sc8800)){
+               if(sc8800->write_tmo){
+                       sc8800_dbg(sc8800->dev, "bp_rts = 0\n");
+                       kfree(buf);
+                       return -1;
+               }
+               schedule();
+       }
+       mutex_lock(&sc8800s_lock);
+       ap_rts(sc8800,0);
+#if 1
+       while(bp_rdy(sc8800)){
+               if(sc8800->write_tmo){
+                       ap_rts(sc8800,1);
+                       sc8800_dbg(sc8800->dev, "ERR: %s write timeout ->bp not ready (bp_rdy = 1)\n", __func__);
+                       kfree(buf);
+                       mutex_unlock(&sc8800s_lock);
+                       return -1;
+               }
+               schedule();
+       }
+#endif
+       len = sc8800_data_packet(buf, sc8800->tx_buf, sc8800->tx_len);
+       spi_in(sc8800, buf, len, &ret);
+
+       if(ret < 0)
+               dev_err(sc8800->dev, "ERR: %s spi in err = %d\n", __func__, ret);
+       ap_rts(sc8800,1);
+       if(buf){
+               kfree(buf);
+               buf = NULL;
+       }
+
+       mutex_unlock(&sc8800s_lock);
+#if 1  
+       while(!bp_rdy(sc8800)){
+               if(sc8800->write_tmo){
+                       dev_err(sc8800->dev, "ERR: %s write timeout -> bp receiving (bp_rdy = 0)\n", __func__);
+                       ret = -1;
+               }
+               schedule();
+       }
+#endif
+       return ret;
+}
+
+static irqreturn_t sc8800_irq(int irq, void *dev_id)
+{
+       struct sc8800_data *sc8800 = (struct sc8800_data *)dev_id;
+       
+       sc8800_dbg(sc8800->dev, "%s\n", __func__);
+#if 0
+       if(sc8800->is_suspend)
+               rk28_send_wakeup_key();
+#endif
+       wake_lock(&sc8800->rx_wake);
+       queue_work(sc8800->rx_wq, &sc8800->rx_work);
+       return IRQ_HANDLED;
+}
+
+static void sc8800_rx_work(struct work_struct *rx_work)
+{
+       struct sc8800_data *sc8800 = container_of(rx_work, struct sc8800_data, rx_work);
+       
+       sc8800_dbg(sc8800->dev, "%s\n", __func__);
+       mutex_lock(&sc8800s_lock);
+       sc8800->rx_len = sc8800_rx(sc8800);
+       wake_unlock(&sc8800->rx_wake);
+       if(sc8800->rx_len <= 0)
+               sc8800->rx_len = 0;
+       wake_up(&sc8800->waitrq);
+       mutex_unlock(&sc8800s_lock);
+}
+static void sc8800_tx_work(struct work_struct *tx_work)
+{
+       struct sc8800_data *sc8800 = container_of(tx_work, struct sc8800_data, tx_work);
+
+       sc8800_dbg(sc8800->dev, "%s bp_rts = %d\n", __func__, bp_rts(sc8800));
+       wake_lock(&sc8800->tx_wake);
+       if(sc8800_tx(sc8800) == 0){
+               sc8800->write_finished = 1;
+               wake_up(&sc8800->waitwq);
+       }
+       wake_unlock(&sc8800->tx_wake);
+}
+static ssize_t sc8800_read(struct file *file,
+                       char __user *buf, size_t count, loff_t *offset)
+{
+       int ret = 0;
+       ssize_t size = 0;
+       struct sc8800_data *sc8800 = (struct sc8800_data *)file->private_data;
+
+       sc8800_dbg(sc8800->dev, "%s count = %d\n", __func__, count);
+       if(!buf){
+               dev_err(sc8800->dev, "ERR: %s user_buf = NULL\n", __func__);
+               return -EFAULT;
+       }
+       down_write(&sc8800_rsem);
+       if(!(file->f_flags & O_NONBLOCK)){
+               ret = wait_event_interruptible(sc8800->waitrq, (sc8800->rx_len > 0 || (sc8800->rw_enable <= 0)));
+               if (ret) {
+                       up_write(&sc8800_rsem);
+                       return ret;
+               }
+       }
+       if(sc8800->rw_enable <= 0){
+               dev_err(sc8800->dev, "ERR: %s sc8800 is released\n", __func__);
+               up_write(&sc8800_rsem);
+               return -EFAULT;
+       }
+       if(sc8800->rx_len == 0){
+               dev_warn(sc8800->dev, "WARN: %s nonblock read, rx_len = 0\n", __func__);
+               return 0;
+       }
+       spin_lock(&sc8800->lock);
+       sc8800_print_buf(sc8800, sc8800->rx_buf, __func__, sc8800->rx_len);
+       if(sc8800->rx_len > count){
+               size = count;
+               ret = copy_to_user(buf, sc8800->rx_buf, count);
+       }else{
+               size = sc8800->rx_len;
+               ret = copy_to_user(buf, sc8800->rx_buf, sc8800->rx_len);
+       }
+
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: %s copy to user ret = %d\n", __func__, ret);
+               spin_unlock(&sc8800->lock);
+               up_write(&sc8800_rsem);
+               return -EFAULT;
+       }
+       if(sc8800->rx_len > count)
+               memmove(sc8800->rx_buf, sc8800->rx_buf + count, sc8800->rx_len - count);
+       
+       sc8800->rx_len -= size;
+       spin_unlock(&sc8800->lock);
+       up_write(&sc8800_rsem);
+       return size;
+}
+static ssize_t sc8800_write(struct file *file, 
+                       const char __user *buf, size_t count, loff_t *offset)
+{
+       int ret = 0;
+       struct sc8800_data *sc8800 = (struct sc8800_data *)file->private_data;
+
+       sc8800_dbg(sc8800->dev, "%s count = %d\n", __func__, count);
+       if(count > WR_BUF_SIZE){
+               dev_err(sc8800->dev, "ERR: %s count[%u] > WR_BUF_SIZE[%lu]\n",
+                               __func__, count, WR_BUF_SIZE);
+               return -EFAULT; 
+       }
+       down_write(&sc8800_wsem);
+       sc8800_print_buf(sc8800, sc8800->tx_buf, __func__, count);
+       memset(sc8800->tx_buf, 0, WR_BUF_SIZE);
+       ret = copy_from_user(sc8800->tx_buf, buf, count);
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: %s copy from user ret = %d\n", __func__, ret);
+               up_write(&sc8800_wsem);
+               return -EFAULT;
+       }
+
+       sc8800->write_finished = 0;
+       sc8800->tx_len = count;
+       queue_work(sc8800->tx_wq, &sc8800->tx_work);
+
+       ret = wait_event_timeout(sc8800->waitwq,
+                               (sc8800->write_finished || sc8800->rw_enable <= 0),
+                               msecs_to_jiffies(WRITE_TIMEOUT));
+       if(sc8800->rw_enable <= 0){
+               dev_err(sc8800->dev, "ERR: %ssc8800 is released\n", __func__);
+               up_write(&sc8800_wsem);
+               return  -EFAULT;
+       }
+       if(ret == 0){
+               sc8800->write_tmo = 1;
+               dev_err(sc8800->dev, "ERR: %swrite timeout\n", __func__);
+               up_write(&sc8800_wsem);
+               return -ETIMEDOUT;
+               //return count;
+       }else{
+               up_write(&sc8800_wsem);
+               return count;
+       }
+}
+
+static int sc8800_open(struct inode *inode, struct file *file)
+{
+       file->private_data = g_sc8800;
+       
+       sc8800_dbg(g_sc8800->dev, "%s\n", __func__);
+       g_sc8800->write_finished = 0;
+       g_sc8800->write_tmo = 0;
+       g_sc8800->rw_enable++;
+       return 0;
+}
+static int sc8800_release(struct inode *inode, struct file *file)
+{
+       struct sc8800_data *sc8800 = (struct sc8800_data *)file->private_data;
+
+       sc8800_dbg(sc8800->dev, "%s\n", __func__);
+       if(sc8800->rw_enable > 0)
+               sc8800->rw_enable--;
+       wake_up(&sc8800->waitrq);
+       wake_up(&sc8800->waitwq);
+
+       return 0;
+}
+static const struct file_operations sc8800_fops = {
+       .open = sc8800_open,
+       .release = sc8800_release,
+       .read = sc8800_read,
+       .write = sc8800_write,
+};
+static struct miscdevice sc8800_device = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "sc8800",
+       .fops = &sc8800_fops,
+};
+
+static int __devinit sc8800_probe(struct spi_device *spi)
+{
+       int ret = 0;
+       unsigned long page;
+       struct sc8800_data *sc8800 = NULL;
+       struct plat_sc8800 *pdata = NULL;
+
+       pdata = spi->dev.platform_data;
+       if (!pdata) {
+               dev_err(&spi->dev, "ERR: spi data missing\n");
+               return -ENODEV;
+       }
+
+       sc8800 = (struct sc8800_data *)kzalloc(sizeof(struct sc8800_data), GFP_KERNEL);
+       if(!sc8800){
+               dev_err(&spi->dev, "ERR: no memory for sc8800\n");
+               return -ENOMEM;
+       }
+       g_sc8800 = sc8800;
+
+       page = __get_free_pages(GFP_KERNEL, 4); //2^4 * 4K = 64K
+       if(!page){
+               dev_err(&spi->dev, "ERR: no memory for rx_buf\n");
+               ret = -ENOMEM;
+               goto err_get_free_page1;
+       }
+       sc8800->rx_buf = (char *)page;
+
+       page = __get_free_pages(GFP_KERNEL, 1);//2^1 * 4K = 8K
+       if(!page){
+               dev_err(&spi->dev, "ERR: no memory for tx_buf\n");
+               ret = -ENOMEM;
+               goto err_get_free_page2;
+       }
+       sc8800->tx_buf = (char *)page;
+
+       sc8800->spi = spi;
+       sc8800->dev = &spi->dev;
+       dev_set_drvdata(sc8800->dev, sc8800);
+
+       spi->bits_per_word = 16;
+       spi->mode = SPI_MODE_2;
+       spi->max_speed_hz = 1000*1000*8;
+       ret = spi_setup(spi);
+       if (ret < 0){
+               dev_err(sc8800->dev, "ERR: fail to setup spi\n");
+               goto err_spi_setup;
+       }
+       sc8800->irq = gpio_to_irq(pdata->slav_rts_pin);
+       sc8800->slav_rts = pdata->slav_rts_pin;
+       sc8800->slav_rdy = pdata->slav_rdy_pin;
+       sc8800->master_rts = pdata->master_rts_pin;
+       sc8800->master_rdy = pdata->master_rdy_pin;
+
+        rk29_mux_api_set(GPIO1C1_UART0RTSN_SDMMC1WRITEPRT_NAME, GPIO1H_GPIO1C1);
+        rk29_mux_api_set(GPIO1C0_UART0CTSN_SDMMC1DETECTN_NAME, GPIO1H_GPIO1C0);
+
+       ret = gpio_request(sc8800->slav_rts, "salv_rts");
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: gpio request slav_rts[%d]\n", sc8800->slav_rts);
+               goto err_gpio_request_slav_rts;
+       }
+       ret = gpio_request(sc8800->slav_rdy, "slav_rdy");
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: gpio request slav_rdy\n");
+               goto err_gpio_request_slav_rdy;
+       }
+       ret = gpio_request(sc8800->master_rts, "master_rts");
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: gpio request master_rts\n");
+               goto err_gpio_request_master_rts;
+       }
+       ret = gpio_request(sc8800->master_rdy, "master_rdy");
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: gpio request master_rdy\n");
+               goto err_gpio_request_master_rdy;
+       }
+       gpio_direction_input(sc8800->slav_rts);
+       gpio_pull_updown(sc8800->slav_rts, GPIOPullUp);
+       gpio_direction_input(sc8800->slav_rdy);
+       gpio_pull_updown(sc8800->slav_rdy, GPIOPullUp);
+       gpio_direction_output(sc8800->master_rts, GPIO_HIGH);
+       gpio_direction_output(sc8800->master_rdy, GPIO_HIGH);
+
+       
+       init_waitqueue_head(&sc8800->waitrq);
+       init_waitqueue_head(&sc8800->waitwq);
+       spin_lock_init(&sc8800->lock);
+
+       ret = misc_register(&sc8800_device);
+       if(ret < 0){
+       
+               dev_err(sc8800->dev, "ERR: fail to register misc device\n");
+               goto err_misc_register;
+       }
+       ret = request_irq(sc8800->irq, sc8800_irq, IRQF_TRIGGER_FALLING, "sc8800", sc8800);
+       if(ret < 0){
+               dev_err(sc8800->dev, "ERR: fail to request irq %d\n", sc8800->irq);
+               goto err_request_irq;
+       }
+       wake_lock_init(&sc8800->rx_wake, WAKE_LOCK_SUSPEND, "sc8800_rx_wake");
+       wake_lock_init(&sc8800->tx_wake, WAKE_LOCK_SUSPEND, "sc8800_tx_wake");
+       enable_irq_wake(sc8800->irq);
+       sc8800->rx_wq = create_workqueue("sc8800_rxwq"); 
+       sc8800->tx_wq = create_workqueue("sc8800_txwq"); 
+       INIT_WORK(&sc8800->rx_work, sc8800_rx_work);
+       INIT_WORK(&sc8800->tx_work, sc8800_tx_work);
+       dev_info(sc8800->dev, "sc8800 probe ok\n");
+       return 0;
+
+err_request_irq:
+       gpio_free(sc8800->master_rdy);
+err_misc_register:
+       misc_deregister(&sc8800_device);
+err_gpio_request_master_rdy:
+       gpio_free(sc8800->master_rts);
+err_gpio_request_master_rts:
+       gpio_free(sc8800->slav_rdy);
+err_gpio_request_slav_rdy:
+       gpio_free(sc8800->slav_rts);
+err_gpio_request_slav_rts:
+err_spi_setup:
+       free_page((unsigned long)sc8800->tx_buf);
+err_get_free_page2:
+       free_page((unsigned long)sc8800->rx_buf);
+err_get_free_page1:
+       kfree(sc8800);
+       sc8800 = NULL;
+       g_sc8800 = NULL;
+       return ret;
+}
+
+static int __devexit sc8800_remove(struct spi_device *spi)
+{
+       struct sc8800_data *sc8800 = dev_get_drvdata(&spi->dev);
+
+       destroy_workqueue(sc8800->rx_wq); 
+       destroy_workqueue(sc8800->tx_wq); 
+       free_irq(sc8800->irq, sc8800);
+       gpio_free(sc8800->master_rdy);
+       gpio_free(sc8800->master_rts);
+       gpio_free(sc8800->slav_rdy);
+       gpio_free(sc8800->slav_rts);
+       free_page((unsigned long)sc8800->tx_buf);
+       free_page((unsigned long)sc8800->rx_buf);
+       kfree(sc8800);
+       sc8800 = NULL;
+       return 0;
+}
+
+#ifdef CONFIG_PM
+
+static int sc8800_suspend(struct spi_device *spi, pm_message_t state)
+{
+       struct sc8800_data *sc8800 = dev_get_drvdata(&spi->dev);
+
+       sc8800->is_suspend = 1; 
+       return 0;
+}
+
+static int sc8800_resume(struct spi_device *spi)
+{
+       struct sc8800_data *sc8800 = dev_get_drvdata(&spi->dev);
+
+
+       sc8800->is_suspend = 0; 
+       return 0;
+}
+
+#else
+#define sc8800_suspend NULL
+#define sc8800_resume  NULL
+#endif
+
+static struct spi_driver sc8800_driver = {
+       .driver = {
+               .name           = "sc8800",
+               .bus            = &spi_bus_type,
+               .owner          = THIS_MODULE,
+       },
+
+       .probe          = sc8800_probe,
+       .remove         = __devexit_p(sc8800_remove),
+       .suspend        = sc8800_suspend,
+       .resume         = sc8800_resume,
+};
+
+static int __init sc8800_init(void)
+{
+       printk("sc8800_init\n");
+       return spi_register_driver(&sc8800_driver);
+}
+module_init(sc8800_init);
+
+static void __exit sc8800_exit(void)
+{
+       spi_unregister_driver(&sc8800_driver);
+}
+module_exit(sc8800_exit);
+
+MODULE_DESCRIPTION("SC8800 driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("spi:SC8800");
diff --git a/drivers/misc/tdsc8800.c b/drivers/misc/tdsc8800.c
new file mode 100755 (executable)
index 0000000..d30d82c
--- /dev/null
@@ -0,0 +1,179 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/i2c.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/miscdevice.h>
+#include <linux/circ_buf.h>
+#include <linux/interrupt.h>
+#include <linux/miscdevice.h>
+#include <mach/iomux.h>
+#include <mach/gpio.h>
+#include <linux/delay.h>
+#include <linux/poll.h>
+#include <linux/wait.h>
+#include <linux/slab.h>
+
+#include <linux/workqueue.h>
+#include <linux/mtk23d.h>
+
+
+MODULE_LICENSE("GPL");
+
+#define DEBUG
+#ifdef DEBUG
+#define MODEMDBG(x...) printk(x)
+#else
+#define MODEMDBG(fmt,argss...)
+#endif
+
+#define SLEEP 1
+#define READY 0
+struct rk2818_23d_data *gpdata = NULL;
+
+
+int modem_poweron_off(int on_off)
+{
+       struct rk2818_23d_data *pdata = gpdata;
+       
+       if(on_off)
+       {
+               printk("tdsc8800_poweron\n");
+               gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_HIGH:GPIO_LOW);  // power on enable
+
+       }
+       else
+       {
+               printk("tdsc8800_poweroff\n");
+               gpio_set_value(pdata->bp_power, pdata->bp_power_active_low? GPIO_LOW:GPIO_HIGH);
+       }
+       return 0;
+}
+static int tdsc8800_open(struct inode *inode, struct file *file)
+{
+       modem_poweron_off(1);
+       device_init_wakeup(gpdata->dev, 1);
+
+       return 0;
+}
+
+static int tdsc8800_release(struct inode *inode, struct file *file)
+{
+       MODEMDBG("tdsc8800_release\n");
+
+       return 0;
+}
+static long  tdsc8800_ioctl(struct file *file, unsigned int a, unsigned long b)
+{
+       return 0;
+}
+
+static struct file_operations tdsc8800_fops = {
+       .owner = THIS_MODULE,
+       .open =tdsc8800_open,
+       .release =tdsc8800_release,
+       .unlocked_ioctl = tdsc8800_ioctl
+};
+
+static struct miscdevice tdsc8800_misc = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "tdsc8800",
+       .fops = &tdsc8800_fops
+};
+
+static int tdsc8800_probe(struct platform_device *pdev)
+{
+       struct rk2818_23d_data *pdata = gpdata = pdev->dev.platform_data;
+       struct modem_dev *tdsc8800_data = NULL;
+       int result = 0; 
+       
+       MODEMDBG("tdsc8800_probe\n");
+
+       //pdata->io_init();
+
+       pdata->dev = &pdev->dev;
+       tdsc8800_data = kzalloc(sizeof(struct modem_dev), GFP_KERNEL);
+       if(NULL == tdsc8800_data)
+       {
+               printk("failed to request tdsc8800_data\n");
+               goto err6;
+       }
+       platform_set_drvdata(pdev, tdsc8800_data);
+
+       result = gpio_request(pdata->bp_power, "tdsc8800");
+       if (result) {
+               printk("failed to request BP_POW_EN gpio\n");
+               goto err1;
+       }
+       
+       
+        gpio_direction_output(pdata->bp_power, GPIO_LOW);
+
+       gpio_set_value(pdata->bp_power, pdata->bp_reset_active_low? GPIO_LOW:GPIO_HIGH);
+       result = misc_register(&tdsc8800_misc);
+       if(result)
+       {
+               MODEMDBG("misc_register err\n");
+       }
+       MODEMDBG("mtk23d_probe ok\n");
+       
+       return result;
+err1:
+       gpio_free(pdata->bp_power);
+err6:
+       kfree(tdsc8800_data);
+       return result;
+}
+
+int tdsc8800_suspend(struct platform_device *pdev)
+{
+       return 0;
+}
+
+int tdsc8800_resume(struct platform_device *pdev)
+{
+       return 0;
+}
+
+void tdsc8800_shutdown(struct platform_device *pdev, pm_message_t state)
+{
+       struct rk2818_23d_data *pdata = pdev->dev.platform_data;
+       struct modem_dev *mt6223d_data = platform_get_drvdata(pdev);
+       
+       MODEMDBG("%s \n", __FUNCTION__);
+
+       modem_poweron_off(0);  // power down
+       gpio_free(pdata->bp_power);
+       kfree(mt6223d_data);
+}
+
+static struct platform_driver tdsc8800_driver = {
+       .probe  = tdsc8800_probe,
+       .shutdown       = tdsc8800_shutdown,
+       .suspend        = tdsc8800_suspend,
+       .resume         = tdsc8800_resume,
+       .driver = {
+               .name   = "tdsc8800",
+               .owner  = THIS_MODULE,
+       },
+};
+
+static int __init tdsc8800_init(void)
+{
+       int ret = platform_driver_register(&tdsc8800_driver);
+       MODEMDBG("tdsc8800_init ret=%d\n",ret);
+       return ret;
+}
+
+static void __exit tdsc8800_exit(void)
+{
+       MODEMDBG("tdsc8800_exit\n");
+       platform_driver_unregister(&tdsc8800_driver);
+}
+
+module_init(tdsc8800_init);
+module_exit(tdsc8800_exit);
index 991df931d4aa9ac8d3fba0b70517710b6ab036e1..3027be6e850c23fd6cbd61d27e773f04f7e56900 100644 (file)
@@ -44,6 +44,16 @@ choice
            A library for Broadcom BCM4329 SDIO WLAN/BT combo devices.
            So far, the following modules have been verified:
              (1) Samsung    SWL-B23
+             
+       config BCM4319
+         depends on WLAN_80211 && MMC
+         select WIRELESS_EXT
+         select WEXT_PRIV
+         select IEEE80211
+         select FW_LOADER
+         bool "Broadcom BCM4319 WiFi SDIO"
+         ---help---
+           A library for Broadcom BCM4319 SDIO WLAN devices. 
 
        config MV8686
          depends on WLAN_80211 && MMC
@@ -59,11 +69,8 @@ choice
              (3) USI        WM-G-MR-09
              (4) Murata     SP-8HEP-P
 
-source "drivers/net/wireless/bcm4319/Kconfig"
 source "drivers/net/wireless/rtl8192c/Kconfig"
 endchoice
 
-#source "drivers/net/wireless/bcm4329/Kconfig"
-
 endif
 
diff --git a/drivers/net/wireless/bcm4319/ChangeLog.txt b/drivers/net/wireless/bcm4319/ChangeLog.txt
deleted file mode 100644 (file)
index 8782b44..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-===========================================================================\r
-=== Version 1.05 @ 2011-03-26 ===\r
-===========================================================================\r
-\r
-1. ½â¾öÁËÉî¶È˯Ãß15·ÖÖÓºó»½ÐÑÒì³£µÄÎÊÌâ\r
-2. ¿ªÆôCombo-SCANÒÔÖ§³Öwpa_supplicant_6\r
-\r
-===========================================================================\r
-=== Version 1.04 @ 2011-03-21 ===\r
-===========================================================================\r
-\r
-1. ½â¾öÁ˲»ÄÜÕý³£Á¬½ÓAPµÄÎÊÌâ\r
-\r
-===========================================================================\r
-=== Version 1.03 @ 2011-01-24 ===\r
-===========================================================================\r
-\r
-1. Ìí¼Ó¶ÔRK29ƽ̨µÄÖ§³Ö¡£\r
-\r
-===========================================================================\r
-=== Version 1.02 @ 20101102 ===\r
-===========================================================================\r
-\r
-1. ÔÚɨÃèÁбíÖУ¬ÓÐһЩAP¼´Ê¹½Ï½ü£¬ÈÔÈ»»áËÑË÷²»µ½¡£\r
-   =>½«tplinklai¸ÄΪͨµÀ13ºó£¬ÈÔÈ»ÕÒ²»µ½Ëü¡£\r
-   =>·¢ÏÖµ±Ç°µÄ¹¤×÷ģʽÖУ¬Ö»Ö§³ÖɨÃ赽ͨµÀ11¡£\r
-   =>dhd_preinit_ioctlsº¯ÊýÖÐÌí¼ÓÈçϺ¯Êý£º\r
-     dhdcdc_query_ioctl(dhd, 0, WLC_GET_COUNTRY,\r
-                               dhd->country_code, sizeof(dhd->country_code));\r
-     ·¢ÏÖÄ¿Ç°Ä£×éĬÈϵÄCOUNTRY CODEÊÇUS£¬¶øUSÖÐÊÇÖ»Ö§³Ö11¸öͨµÀµÄ¡£\r
-   =>\r
-===========================================================================\r
-=== Version 1.01 @ 20101027 ===\r
-===========================================================================\r
-\r
-1. ¸ÄΪʹÓÃwifi_version.hÖеİ汾¶¨Òå¡£\r
-\r
-2. Í¨¹ýÔÚ°åÉÏnetperf -H 192.168.1.200 -t TCP_STREAM½øÐвâÊÔ£¬»á³öÏÖ£º\r
-    [204] dhd_bus_txdata: out of bus->txq !!!\r
-    [204] dhd_bus_txdata: out of bus->txq !!!\r
-    [205] CMD: 53 <arg=21000020> FAIL raw_ints: 12034 masked ints: 4\r
-    [207] CMD: 52 <arg=12003800> FAIL raw_ints: 11030 masked ints: 1000\r
-    [207] CMD: 52 <arg=12003800> FAIL raw_ints: 11030 masked ints: 1000\r
-    [207] CMD: 52 <arg=12003800> FAIL raw_ints: 11030 masked ints: 1000\r
-    [207] CMD: 52 <arg=12003600> FAIL raw_ints: 11030 masked ints: 1000\r
-    [207] CMD: 52 <arg=12003600> FAIL raw_ints: 11030 masked ints: 1000\r
-\r
-   ÊÖ¶¯ÅäÖÃÃüÁ\r
-     iwconfig wlan0 mode managed\r
-     iwconfig wlan0 essid tplinklai\r
-     ifconfig wlan0 192.168.1.21\r
-     netperf -H 192.168.1.200 -t TCP_STREAM\r
-   \r
-   ÔÚSDIOÇý¶¯ÖУ¬´ò¿ªDATA BUSYµÄ¼ì²â£¬ÔòûÓгöÏÖÎÊÌâ¡£\r
diff --git a/drivers/net/wireless/bcm4319/Kconfig b/drivers/net/wireless/bcm4319/Kconfig
deleted file mode 100644 (file)
index 11aafd3..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-config BCM4319
-       bool "Broadcom 4319 wireless cards support"
-       depends on WLAN_80211 && MMC
-       select WIRELESS_EXT
-       select IEEE80211
-       select FW_LOADER
-       ---help---
-         This module adds support for wireless adapters based on
-         Broadcom 4319 chipset.
-
-         This driver uses the kernel's wireless extensions subsystem.
-
-         If you choose to build a module, it'll be called dhd. Say M if
-         unsure.
diff --git a/drivers/net/wireless/bcm4319/Kconfig.bcm4319 b/drivers/net/wireless/bcm4319/Kconfig.bcm4319
deleted file mode 100644 (file)
index 11aafd3..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-config BCM4319
-       bool "Broadcom 4319 wireless cards support"
-       depends on WLAN_80211 && MMC
-       select WIRELESS_EXT
-       select IEEE80211
-       select FW_LOADER
-       ---help---
-         This module adds support for wireless adapters based on
-         Broadcom 4319 chipset.
-
-         This driver uses the kernel's wireless extensions subsystem.
-
-         If you choose to build a module, it'll be called dhd. Say M if
-         unsure.
index 3c7768f6d7343df6f4a86f843829600699561479..3d9df6a001e23680c28ba45be5f8cfe019e11a8f 100644 (file)
@@ -1,42 +1,24 @@
-
-RKWLCFGDIR = ../wifi_power
-BROADCOM_SRC_DIR = drivers/net/wireless/bcm4319
-
-EXTRA_CFLAGS += -I$(src) -I$(src)/include -I$(src)/$(RKWLCFGDIR)/
-EXTRA_CFLAGS += -DLINUX -DSRCBASE=\"$(BROADCOM_SRC_DIR)\" -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD\
-                -DBCMWPA2 -DBCMWAPI_WPI
-EXTRA_CFLAGS += -DUNRELEASEDCHIP -DOEM_ANDROID -DEMBEDDED_PLATFORM -DARP_OFFLOAD_SUPPORT -DPKT_FILTER_SUPPORT 
-EXTRA_CFLAGS += -DBCMSDIO -DDHD_GPL -DBCMLXSDMMC -DBCMPLATFORM_BUS
-EXTRA_CFLAGS += -DSDIO_ISR_THREAD
-EXTRA_CFLAGS += -DBDC -DTOE -DDHD_BCMEVENTS -DDHD_SCHED -DCSCAN
-#EXTRA_CFLAGS += -DSHOW_EVENTS -DDHD_DEBUG -DSDTEST 
-#EXTRA_CFLAGS += -DBCMSDH_MODULE
-#EXTRA_CFLAGS += -DCONFIG_WIFI_CONTROL_FUNC
-
-
-bcmsdio-objs := bcmsdh.o bcmsdh_linux.o bcmsdh_sdmmc.o \
-                bcmsdh_sdmmc_linux.o
-
-dhd-objs := dhd_common.o  dhd_linux.o dhd_linux_sched.o dhd_sdio.o \
-            dhd_custom_gpio.o dhd_cdc.o
-
-shared-objs := aiutils.o bcmutils.o bcmwifi.o hndpmu.o \
-               linux_osl.o  sbutils.o siutils.o
-
-wl-objs := wl_iw.o
-
-bcm4319-objs := $(bcmsdio-objs) $(dhd-objs) $(shared-objs) $(wl-objs) $(RKWLCFGDIR)/wifi_power_ops.o
-
-obj-$(CONFIG_BCM4319) += bcm4319.o $(RKWLCFGDIR)/wifi_power.o
-
-default:
-       $(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) modules
-clean:
-       rm -rvf *.o *.ko *.mod.c *.o.cmd *.tmp_versions *.mod.o *.cmd modules.order Module.symvers .tmp_versions rkpub
-       find . -name '*.o' -exec rm -f {} \;
-       find . -name '.*.cmd' -exec rm -f {} \;
-.PHONY: clean
-
-
-
-                 
+# bcm4319
+DHDCFLAGS = -DLINUX -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD -DBCMWPA2         \
+       -DUNRELEASEDCHIP -Dlinux -DDHD_SDALIGN=64 -DMAX_HDR_READ=64           \
+       -DDHD_FIRSTREAD=64 -DDHD_GPL -DDHD_SCHED -DBDC -DTOE -DDHD_BCMEVENTS  \
+       -DSHOW_EVENTS -DBCMSDIO -DDHD_GPL -DBCMLXSDMMC -DBCMPLATFORM_BUS      \
+       -Wall -Wstrict-prototypes -Werror -DCUSTOMER_HW2      \
+       -DDHD_USE_STATIC_BUF -DDHD_DEBUG_TRAP -DSOFTAP -DSDIO_ISR_THREAD      \
+       -DEMBEDDED_PLATFORM -DARP_OFFLOAD_SUPPORT -DPKT_FILTER_SUPPORT        \
+       -DGET_CUSTOM_MAC_ENABLE -DSET_RANDOM_MAC_SOFTAP -DCSCAN   \
+        -DKEEP_ALIVE -DCONFIG_US_NON_DFS_CHANNELS_ONLY   \
+       -Idrivers/net/wireless/bcm4319 -Idrivers/net/wireless/bcm4319/include
+
+#options defines dependent on platform board and applicantion requirements: 
+#-DOOB_INTR_ONLY -DMMC_SDIO_ABORT -DHW_OOB
+
+DHDOFILES = dhd_linux.o linux_osl.o bcmutils.o dhd_common.o dhd_custom_gpio.o \
+       wl_iw.o siutils.o sbutils.o aiutils.o hndpmu.o bcmwifi.o dhd_sdio.o   \
+       dhd_linux_sched.o dhd_cdc.o bcmsdh_sdmmc.o bcmsdh.o bcmsdh_linux.o    \
+       bcmsdh_sdmmc_linux.o
+
+obj-$(CONFIG_BCM4319) += bcm4319.o
+bcm4319-objs += $(DHDOFILES)
+EXTRA_CFLAGS = $(DHDCFLAGS)
+EXTRA_LDFLAGS += --strip-debug
diff --git a/drivers/net/wireless/bcm4319/Makefile.bcm4319 b/drivers/net/wireless/bcm4319/Makefile.bcm4319
deleted file mode 100644 (file)
index 97a3655..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-
-EXTRA_CFLAGS += -I$(src)
-
-rkcfg-y := \
-    wifi_power.o \
-
-obj-$(CONFIG_BCM4319)          += bcm4319.o rkcfg.o
-
-$(obj)/bcm4319.o: $(obj)/bcm4319.uu
-       @echo "UUDE    bcm4319.uu"
-       @uudecode $(obj)/bcm4319.uu -o $(obj)/bcm4319.o
-
-
index c0a66f1aa3e4aabe9da3615ef165df84c106e6b4..1a8b6717f9244028e9f6e86ad5aa95dd2a845174 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmpcispi.c,v 1.22.2.4.4.5 2008/07/09 21:23:30 Exp $
+ * $Id: bcmpcispi.c,v 1.22.2.4.4.5.6.1 2010/08/13 00:26:05 Exp $
  */
 
 #include <typedefs.h>
@@ -606,18 +606,23 @@ spi_spinbits(sdioh_info_t *sd)
        spin_count = 0;
        while ((SPIPCI_RREG(sd->osh, &regs->spih_stat) & SPIH_WFEMPTY) == 0) {
                if (spin_count > SPI_SPIN_BOUND) {
-                       ASSERT(FALSE); /* Spin bound exceeded */
+                       sd_err(("%s: SPIH_WFEMPTY spin bits out of bound %u times \n",
+                               __FUNCTION__, spin_count));
+                       ASSERT(FALSE);
                }
                spin_count++;
        }
-       spin_count = 0;
+
        /* Wait for SPI Transfer state machine to return to IDLE state.
         * The state bits are only implemented in Rev >= 5 FPGA.  These
         * bits are hardwired to 00 for Rev < 5, so this check doesn't cause
         * any problems.
         */
+       spin_count = 0;
        while ((SPIPCI_RREG(osh, &regs->spih_stat) & SPIH_STATE_MASK) != 0) {
                if (spin_count > SPI_SPIN_BOUND) {
+                       sd_err(("%s: SPIH_STATE_MASK spin bits out of bound %u times \n",
+                               __FUNCTION__, spin_count));
                        ASSERT(FALSE);
                }
                spin_count++;
index e6241cc4bc590b875d3512aae1ef98c0bd6816a9..cdb2c5e1f1ecf714b377580195218d14e42cca86 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdh_linux.c,v 1.42.10.10.2.12 2010/03/10 03:09:48 Exp $
+ * $Id: bcmsdh_linux.c,v 1.42.10.10.2.14.4.2 2010/09/15 00:30:11 Exp $
  */
 
 /**
@@ -76,6 +76,10 @@ struct bcmsdh_hc {
        void *ch;
        unsigned int oob_irq;
        unsigned long oob_flags; /* OOB Host specifiction as edge and etc */
+       bool oob_irq_registered;
+#if defined(OOB_INTR_ONLY)
+       spinlock_t irq_lock;
+#endif
 };
 static bcmsdh_hc_t *sdhcinfo = NULL;
 
@@ -187,7 +191,12 @@ int bcmsdh_probe(struct device *dev)
 #endif /* BCMLXSDMMC */
 
 #if defined(OOB_INTR_ONLY)
-       irq_flags = IRQF_TRIGGER_FALLING;
+#ifdef HW_OOB
+       irq_flags = \
+               IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE;
+#else
+        irq_flags = IRQF_TRIGGER_FALLING;
+#endif /* HW_OOB */
        irq = dhd_customer_oob_irq_map(&irq_flags);
        if  (irq < 0) {
                SDLX_MSG(("%s: Host irq is not defined\n", __FUNCTION__));
@@ -226,6 +235,10 @@ int bcmsdh_probe(struct device *dev)
        sdhc->sdh = sdh;
        sdhc->oob_irq = irq;
        sdhc->oob_flags = irq_flags;
+       sdhc->oob_irq_registered = FALSE;       /* to make sure.. */
+#if defined(OOB_INTR_ONLY)
+       spin_lock_init(&sdhc->irq_lock);
+#endif
 
        /* chain SDIO Host Controller info together */
        sdhc->next = sdhcinfo;
@@ -332,18 +345,18 @@ static struct pci_driver bcmsdh_pci_driver = {
 #endif
        suspend:        NULL,
        resume:         NULL,
-       };
+};
 
 
 extern uint sd_pci_slot;       /* Force detection to a particular PCI */
-                                                       /* slot only . Allows for having multiple */
-                                                       /* WL devices at once in a PC */
-                                                       /* Only one instance of dhd will be */
-                                                       /* useable at a time */
-                                                       /* Upper word is bus number, */
-                                                       /* lower word is slot number */
-                                                       /* Default value of 0xFFFFffff turns this */
-                                                       /* off */
+                               /* slot only . Allows for having multiple */
+                               /* WL devices at once in a PC */
+                               /* Only one instance of dhd will be */
+                               /* usable at a time */
+                               /* Upper word is bus number, */
+                               /* lower word is slot number */
+                               /* Default value of 0xFFFFffff turns this */
+                               /* off */
 module_param(sd_pci_slot, uint, 0);
 
 
@@ -366,20 +379,21 @@ bcmsdh_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                if (pdev->bus->number != (sd_pci_slot>>16) ||
                        PCI_SLOT(pdev->devfn) != (sd_pci_slot&0xffff)) {
                        SDLX_MSG(("%s: %s: bus %X, slot %X, vend %X, dev %X\n",
-                               __FUNCTION__,
-                               bcmsdh_chipmatch(pdev->vendor, pdev->device)
-                               ?"Found compatible SDIOHC"
-                               :"Probing unknown device",
-                               pdev->bus->number, PCI_SLOT(pdev->devfn), pdev->vendor,
-                               pdev->device));
+                                 __FUNCTION__,
+                                 bcmsdh_chipmatch(pdev->vendor, pdev->device) ?
+                                 "Found compatible SDIOHC" :
+                                 "Probing unknown device",
+                                 pdev->bus->number, PCI_SLOT(pdev->devfn),
+                                 pdev->vendor, pdev->device));
                        return -ENODEV;
                }
                SDLX_MSG(("%s: %s: bus %X, slot %X, vendor %X, device %X (good PCI location)\n",
-                       __FUNCTION__,
-                       bcmsdh_chipmatch(pdev->vendor, pdev->device)
-                       ?"Using compatible SDIOHC"
-                       :"WARNING, forced use of unkown device",
-                       pdev->bus->number, PCI_SLOT(pdev->devfn), pdev->vendor, pdev->device));
+                         __FUNCTION__,
+                         bcmsdh_chipmatch(pdev->vendor, pdev->device) ?
+                         "Using compatible SDIOHC" :
+                         "WARNING, forced use of unkown device",
+                         pdev->bus->number, PCI_SLOT(pdev->devfn),
+                         pdev->vendor, pdev->device));
        }
 
        if ((pdev->vendor == VENDOR_TI) && ((pdev->device == PCIXX21_FLASHMEDIA_ID) ||
@@ -440,7 +454,7 @@ bcmsdh_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        pci_set_master(pdev);
        rc = pci_enable_device(pdev);
        if (rc) {
-               SDLX_MSG(("%s: Cannot enble PCI device\n", __FUNCTION__));
+               SDLX_MSG(("%s: Cannot enable PCI device\n", __FUNCTION__));
                goto err;
        }
        if (!(sdh = bcmsdh_attach(osh, (void *)(uintptr)pci_resource_start(pdev, 0),
@@ -521,8 +535,28 @@ bcmsdh_register(bcmsdh_driver_t *driver)
 
        drvinfo = *driver;
 
+#if defined(BCMPLATFORM_BUS)
+#if defined(BCMLXSDMMC)
        SDLX_MSG(("Linux Kernel SDIO/MMC Driver\n"));
        error = sdio_function_init();
+#else
+       SDLX_MSG(("Intel PXA270 SDIO Driver\n"));
+       error = driver_register(&bcmsdh_driver);
+#endif /* defined(BCMLXSDMMC) */
+       return error;
+#endif /* defined(BCMPLATFORM_BUS) */
+
+#if !defined(BCMPLATFORM_BUS) && !defined(BCMLXSDMMC)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
+       if (!(error = pci_module_init(&bcmsdh_pci_driver)))
+               return 0;
+#else
+       if (!(error = pci_register_driver(&bcmsdh_pci_driver)))
+               return 0;
+#endif
+
+       SDLX_MSG(("%s: pci_module_init failed 0x%x\n", __FUNCTION__, error));
+#endif /* BCMPLATFORM_BUS */
 
        return error;
 }
@@ -548,20 +582,35 @@ bcmsdh_unregister(void)
 }
 
 #if defined(OOB_INTR_ONLY)
+void bcmsdh_oob_intr_set(bool enable)
+{
+       static bool curstate = 1;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sdhcinfo->irq_lock, flags);
+       if (curstate != enable) {
+               if (enable)
+                       enable_irq(sdhcinfo->oob_irq);
+               else
+                       disable_irq_nosync(sdhcinfo->oob_irq);
+               curstate = enable;
+       }
+       spin_unlock_irqrestore(&sdhcinfo->irq_lock, flags);
+}
+
 static irqreturn_t wlan_oob_irq(int irq, void *dev_id)
 {
        dhd_pub_t *dhdp;
 
        dhdp = (dhd_pub_t *)dev_get_drvdata(sdhcinfo->dev);
 
+       bcmsdh_oob_intr_set(0);
+
        if (dhdp == NULL) {
-               disable_irq(sdhcinfo->oob_irq);
                SDLX_MSG(("Out of band GPIO interrupt fired way too early\n"));
                return IRQ_HANDLED;
        }
 
-       WAKE_LOCK_TIMEOUT(dhdp, WAKE_LOCK_TMOUT, 25);
-
        dhdsdio_isr((void *)dhdp->bus);
 
        return IRQ_HANDLED;
@@ -573,21 +622,41 @@ int bcmsdh_register_oob_intr(void * dhdp)
 
        SDLX_MSG(("%s Enter\n", __FUNCTION__));
 
-       dev_set_drvdata(sdhcinfo->dev, dhdp);
-
+/* Example of  HW_OOB for HW2: please refer to your host  specifiction */
+/* sdhcinfo->oob_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE; */
 
-       /* Refer to customer Host IRQ docs about proper irqflags definition */
-       error = request_irq(sdhcinfo->oob_irq, wlan_oob_irq, sdhcinfo->oob_flags,
-               "bcmsdh_sdmmc", NULL);
+       dev_set_drvdata(sdhcinfo->dev, dhdp);
 
-       if (error)
-               return -ENODEV;
+       if (!sdhcinfo->oob_irq_registered) {
+               SDLX_MSG(("%s IRQ=%d Type=%X \n", __FUNCTION__, \
+                               (int)sdhcinfo->oob_irq, (int)sdhcinfo->oob_flags));
+               /* Refer to customer Host IRQ docs about proper irqflags definition */
+               error = request_irq(sdhcinfo->oob_irq, wlan_oob_irq, sdhcinfo->oob_flags,
+                       "bcmsdh_sdmmc", NULL);
+               if (error)
+                       return -ENODEV;
 
-       set_irq_wake(sdhcinfo->oob_irq, 1);
+               set_irq_wake(sdhcinfo->oob_irq, 1);
+               sdhcinfo->oob_irq_registered = TRUE;
+       }
 
        return 0;
 }
 
+void bcmsdh_set_irq(int flag)
+{
+       if (sdhcinfo->oob_irq_registered) {
+               SDLX_MSG(("%s Flag = %d", __FUNCTION__, flag));
+               if (flag) {
+                       enable_irq(sdhcinfo->oob_irq);
+                       enable_irq_wake(sdhcinfo->oob_irq);
+               } else {
+                       disable_irq_wake(sdhcinfo->oob_irq);
+                       disable_irq(sdhcinfo->oob_irq);
+               }
+       }
+}
+
 void bcmsdh_unregister_oob_intr(void)
 {
        SDLX_MSG(("%s: Enter\n", __FUNCTION__));
@@ -595,14 +664,7 @@ void bcmsdh_unregister_oob_intr(void)
        set_irq_wake(sdhcinfo->oob_irq, 0);
        disable_irq(sdhcinfo->oob_irq); /* just in case.. */
        free_irq(sdhcinfo->oob_irq, NULL);
-}
-
-void bcmsdh_oob_intr_set(bool enable)
-{
-       if (enable)
-               enable_irq(sdhcinfo->oob_irq);
-       else
-               disable_irq(sdhcinfo->oob_irq);
+       sdhcinfo->oob_irq_registered = FALSE;
 }
 #endif /* defined(OOB_INTR_ONLY) */
 /* Module parameters specific to each host-controller driver */
index 7948bbe97d2eab5381decaf86900579af52f9a93..031367b8f18f996f6ccf50d64909ca3fa111b460 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdh_sdmmc.c,v 1.1.2.5.6.29 2010/03/19 17:16:08 Exp $
+ * $Id: bcmsdh_sdmmc.c,v 1.1.2.5.6.30.4.1 2010/09/02 23:12:21 Exp $
  */
 #include <typedefs.h>
 
@@ -55,7 +55,7 @@ extern void sdio_function_cleanup(void);
 #if !defined(OOB_INTR_ONLY)
 static void IRQHandler(struct sdio_func *func);
 static void IRQHandlerF2(struct sdio_func *func);
-#endif
+#endif /* !defined(OOB_INTR_ONLY) */
 static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, uint32 regaddr);
 extern int sdio_reset_comm(struct mmc_card *card);
 
@@ -675,6 +675,7 @@ sdioh_enable_hw_oob_intr(sdioh_info_t *sd, bool enable)
                data = 3;       /* enable hw oob interrupt */
        else
                data = 4;       /* disable hw oob interrupt */
+       data |= 4;              /* Active HIGH */
 
        status = sdioh_request_byte(sd, SDIOH_WRITE, 0, 0xf2, &data);
        return status;
@@ -1064,14 +1065,18 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write, u
        return (Status);
 }
 
+/* this function performs "abort" for both of host & device */
 extern int
 sdioh_abort(sdioh_info_t *sd, uint func)
 {
+#if defined(MMC_SDIO_ABORT)
+       char t_func = (char) func;
+#endif /* defined(MMC_SDIO_ABORT) */
        sd_trace(("%s: Enter\n", __FUNCTION__));
 
 #if defined(MMC_SDIO_ABORT)
        /* issue abort cmd52 command through F1 */
-       sdioh_request_byte(sd, SD_IO_OP_WRITE, SDIO_FUNC_0, SDIOD_CCCR_IOABORT, (uint8 *)&func);
+       sdioh_request_byte(sd, SD_IO_OP_WRITE, SDIO_FUNC_0, SDIOD_CCCR_IOABORT, &t_func);
 #endif /* defined(MMC_SDIO_ABORT) */
 
        sd_trace(("%s: Exit\n", __FUNCTION__));
@@ -1215,9 +1220,9 @@ sdioh_start(sdioh_info_t *si, int stage)
                   2.6.27. The implementation prior to that is buggy, and needs broadcom's
                   patch for it
                */
-//             if ((ret = sdio_reset_comm(gInstance->func[0]->card)))
-//                     sd_err(("%s Failed, error = %d\n", __FUNCTION__, ret));
-//             else {
+               if ((ret = sdio_reset_comm(gInstance->func[0]->card)))
+                       sd_err(("%s Failed, error = %d\n", __FUNCTION__, ret));
+               else {
                        sd->num_funcs = 2;
                        sd->sd_blockmode = TRUE;
                        sd->use_client_ints = TRUE;
@@ -1250,7 +1255,7 @@ sdioh_start(sdioh_info_t *si, int stage)
                        }
 
                        sdioh_sdmmc_card_enablefuncs(sd);
-//                     }
+                       }
                } else {
 #if !defined(OOB_INTR_ONLY)
                        sdio_claim_host(gInstance->func[0]);
index f52207e3225af44ea092c30a7f44e1a3d011dfaf..8992a4267f9f78ab6047a3f929dc4fef3a9f55d5 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdh_sdmmc_linux.c,v 1.1.2.5.6.15 2010/04/14 21:11:46 Exp $
+ * $Id: bcmsdh_sdmmc_linux.c,v 1.1.2.5.6.17 2010/08/13 00:36:19 Exp $
  */
 
 #include <typedefs.h>
 
 #include <linux/mmc/core.h>
 #include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
 
 #if !defined(SDIO_VENDOR_ID_BROADCOM)
 #define SDIO_VENDOR_ID_BROADCOM                0x02d0
-#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */
+#endif /* !defined(SDIO_VENDOR_ID_BROADCOM) */
+
+#define SDIO_DEVICE_ID_BROADCOM_DEFAULT        0x0000
+
+#if !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB)
+#define SDIO_DEVICE_ID_BROADCOM_4325_SDGWB     0x0492  /* BCM94325SDGWB */
+#endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) */
 #if !defined(SDIO_DEVICE_ID_BROADCOM_4325)
-#define SDIO_DEVICE_ID_BROADCOM_4325   0x0000
+#define SDIO_DEVICE_ID_BROADCOM_4325   0x0493
 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4325) */
 #if !defined(SDIO_DEVICE_ID_BROADCOM_4329)
 #define SDIO_DEVICE_ID_BROADCOM_4329   0x4329
 #define SDIO_DEVICE_ID_BROADCOM_4319   0x4319
 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */
 
-
 #include <bcmsdh_sdmmc.h>
 
 #include <dhd_dbg.h>
 
-
-struct sdio_func *wifi_sdio_func = NULL;
-EXPORT_SYMBOL(wifi_sdio_func);
-
 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
 
@@ -113,13 +113,9 @@ static int bcmsdh_sdmmc_probe(struct sdio_func *func,
                ret = bcmsdh_probe(&sdmmc_dev);
        }
 
-       wifi_sdio_func = func;
-       //printk("get wifi_sdio_func\n");
-
        return ret;
 }
 
-extern int wifi_func_removed;
 static void bcmsdh_sdmmc_remove(struct sdio_func *func)
 {
        sd_trace(("bcmsdh_sdmmc: %s Enter\n", __FUNCTION__));
@@ -129,16 +125,15 @@ static void bcmsdh_sdmmc_remove(struct sdio_func *func)
        sd_info(("Function#: 0x%04x\n", func->num));
 
        if (func->num == 2) {
-               sd_trace(("F2 found, calling bcmsdh_probe...\n"));
+               sd_trace(("F2 found, calling bcmsdh_remove...\n"));
                bcmsdh_remove(&sdmmc_dev);
        }
-    wifi_func_removed = 1;
-    
-       wifi_sdio_func = NULL;
 }
 
 /* devices we support, null terminated */
 static const struct sdio_device_id bcmsdh_sdmmc_ids[] = {
+       { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_DEFAULT) },
+       { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325_SDGWB) },
        { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4325) },
        { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329) },
        { SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4319) },
@@ -235,8 +230,8 @@ bcmsdh_module_cleanup(void)
        sdio_function_cleanup();
 }
 
-//module_init(bcmsdh_module_init);
-//module_exit(bcmsdh_module_cleanup);
+module_init(bcmsdh_module_init);
+module_exit(bcmsdh_module_cleanup);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION(DESCRIPTION);
@@ -258,6 +253,7 @@ int sdio_function_init(void)
        bzero(&sdmmc_dev, sizeof(sdmmc_dev));
        error = sdio_register_driver(&bcmsdh_sdmmc_driver);
 
+
        return error;
 }
 
index 0b1b575d9629f28e39de3b467dd3e5061c00bfb2..0ca1f8ff8a24f4c8561a028b0edc41ebfa32c4a6 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdstd.c,v 1.64.4.1.4.4.2.17 2010/03/10 03:09:48 Exp $
+ * $Id: bcmsdstd.c,v 1.64.4.1.4.4.2.18 2010/08/17 17:00:48 Exp $
  */
 
 #include <typedefs.h>
@@ -119,7 +119,7 @@ extern void sdstd_wreg16(sdioh_info_t *sd, uint reg, uint16 data);
 void
 sdstd_wreg16(sdioh_info_t *sd, uint reg, uint16 data)
 {
-       *(volatile uint16 *)(sd->mem_space + reg) = (volatile uint16) data;
+       *(volatile uint16 *)(sd->mem_space + reg) = (uint16)data;
        sd_ctrl(("16: W Reg 0x%02x, Data 0x%x\n", reg, data));
 }
 
@@ -129,7 +129,7 @@ sdstd_or_reg16(sdioh_info_t *sd, uint reg, uint16 val)
        volatile uint16 data = *(volatile uint16 *)(sd->mem_space + reg);
        sd_ctrl(("16: OR Reg 0x%02x, Val 0x%x\n", reg, val));
        data |= val;
-       *(volatile uint16 *)(sd->mem_space + reg) = (volatile uint16)data;
+       *(volatile uint16 *)(sd->mem_space + reg) = (uint16)data;
 
 }
 static void
@@ -140,7 +140,7 @@ sdstd_mod_reg16(sdioh_info_t *sd, uint reg, int16 mask, uint16 val)
        sd_ctrl(("16: MOD Reg 0x%02x, Mask 0x%x, Val 0x%x\n", reg, mask, val));
        data &= ~mask;
        data |= (val & mask);
-       *(volatile uint16 *)(sd->mem_space + reg) = (volatile uint16)data;
+       *(volatile uint16 *)(sd->mem_space + reg) = (uint16)data;
 }
 
 
@@ -155,7 +155,7 @@ sdstd_rreg(sdioh_info_t *sd, uint reg)
 static inline void
 sdstd_wreg(sdioh_info_t *sd, uint reg, uint32 data)
 {
-       *(volatile uint32 *)(sd->mem_space + reg) = (volatile uint32)data;
+       *(volatile uint32 *)(sd->mem_space + reg) = (uint32)data;
        sd_ctrl(("32: W Reg 0x%02x, Data 0x%x\n", reg, data));
 
 }
@@ -164,7 +164,7 @@ sdstd_wreg(sdioh_info_t *sd, uint reg, uint32 data)
 static inline void
 sdstd_wreg8(sdioh_info_t *sd, uint reg, uint8 data)
 {
-       *(volatile uint8 *)(sd->mem_space + reg) = (volatile uint8)data;
+       *(volatile uint8 *)(sd->mem_space + reg) = (uint8)data;
        sd_ctrl(("08: W Reg 0x%02x, Data 0x%x\n", reg, data));
 }
 static uint8
@@ -287,7 +287,7 @@ sdioh_detach(osl_t *osh, sdioh_info_t *sd)
        return SDIOH_API_RC_SUCCESS;
 }
 
-/* Configure callback to client when we recieve client interrupt */
+/* Configure callback to client when we receive client interrupt */
 extern SDIOH_API_RC
 sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
 {
@@ -2778,10 +2778,6 @@ sdstd_card_buf(sdioh_info_t *sd, int rw, int func, bool fifo, uint32 addr, int n
                                data++;
                        }
 
-                       /* Handle < 4 bytes.  wlc_pio.c currently (as of 12/20/05) truncates buflen
-                        * to be evenly divisable by 4.  However dongle passes arbitrary lengths,
-                        * so handle it here
-                        */
                        bytes = blocksize % 4;
 
                        /* If no leftover bytes, go to next block */
@@ -2898,7 +2894,8 @@ set_client_block_size(sdioh_info_t *sd, int func, int block_size)
 }
 
 /* Reset and re-initialize the device */
-int sdioh_sdio_reset(sdioh_info_t *si)
+int
+sdioh_sdio_reset(sdioh_info_t *si)
 {
        uint8 hreg;
 
index ad6d6603fccd5fd23a338c8f57bce619f70dab0f..a8b98e2054a040b65b3063053c83b6ee89d2bfbb 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: bcmsdstd_linux.c,v 1.11.18.2 2008/05/28 18:36:56 Exp $
+ * $Id: bcmsdstd_linux.c,v 1.11.18.2.16.1 2010/08/17 17:03:13 Exp $
  */
 
 #include <typedefs.h>
@@ -186,7 +186,9 @@ sdstd_lock(sdioh_info_t *sd)
 
        spin_lock_irqsave(&sdos->lock, flags);
        if (sd->lockcount) {
-               sd_err(("%s: Already locked!\n", __FUNCTION__));
+               sd_err(("%s: Already locked! called from %p\n",
+                      __FUNCTION__,
+                      __builtin_return_address(0)));
                ASSERT(sd->lockcount == 0);
        }
        sdstd_devintr_off(sd);
diff --git a/drivers/net/wireless/bcm4319/bcmspibrcm.c b/drivers/net/wireless/bcm4319/bcmspibrcm.c
new file mode 100644 (file)
index 0000000..0f131a4
--- /dev/null
@@ -0,0 +1,1726 @@
+/*
+ * Broadcom BCMSDH to gSPI Protocol Conversion Layer
+ *
+ * Copyright (C) 2010, Broadcom Corporation
+ * All Rights Reserved.
+ * 
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of Broadcom Corporation.
+ *
+ * $Id: bcmspibrcm.c,v 1.11.2.10.2.9.6.11 2009/05/21 13:21:57 Exp $
+ */
+
+#define HSMODE
+
+#include <typedefs.h>
+
+#include <bcmdevs.h>
+#include <bcmendian.h>
+#include <bcmutils.h>
+#include <osl.h>
+#include <hndsoc.h>
+#include <siutils.h>
+#include <sbchipc.h>
+#include <sbsdio.h>
+#include <spid.h>
+
+#include <bcmsdbus.h>  /* bcmsdh to/from specific controller APIs */
+#include <sdiovar.h>   /* ioctl/iovars */
+#include <sdio.h>
+
+#include <pcicfg.h>
+
+
+#include <bcmspibrcm.h>
+#include <bcmspi.h>
+
+#define F0_RESPONSE_DELAY      16
+#define F1_RESPONSE_DELAY      16
+#define F2_RESPONSE_DELAY      F0_RESPONSE_DELAY
+
+#define CMDLEN         4
+
+#define DWORDMODE_ON (sd->chip == BCM4329_CHIP_ID) && (sd->chiprev == 2) && (sd->dwordmode == TRUE)
+
+/* Globals */
+uint sd_msglevel = 0;
+
+uint sd_hiok = FALSE;          /* Use hi-speed mode if available? */
+uint sd_sdmode = SDIOH_MODE_SPI;               /* Use SD4 mode by default */
+uint sd_f2_blocksize = 64;             /* Default blocksize */
+
+
+uint sd_divisor = 2;
+uint sd_power = 1;             /* Default to SD Slot powered ON */
+uint sd_clock = 1;             /* Default to SD Clock turned ON */
+uint sd_crc = 0;               /* Default to SPI CRC Check turned OFF */
+
+uint8  spi_outbuf[SPI_MAX_PKT_LEN];
+uint8  spi_inbuf[SPI_MAX_PKT_LEN];
+
+/* 128bytes buffer is enough to clear data-not-available and program response-delay F0 bits
+ * assuming we will not exceed F0 response delay > 100 bytes at 48MHz.
+ */
+#define BUF2_PKT_LEN   128
+uint8  spi_outbuf2[BUF2_PKT_LEN];
+uint8  spi_inbuf2[BUF2_PKT_LEN];
+
+/* Prototypes */
+static bool bcmspi_test_card(sdioh_info_t *sd);
+static bool bcmspi_host_device_init_adapt(sdioh_info_t *sd);
+static int bcmspi_set_highspeed_mode(sdioh_info_t *sd, bool hsmode);
+static int bcmspi_cmd_issue(sdioh_info_t *sd, bool use_dma, uint32 cmd_arg,
+                           uint32 *data, uint32 datalen);
+static int bcmspi_card_regread(sdioh_info_t *sd, int func, uint32 regaddr,
+                              int regsize, uint32 *data);
+static int bcmspi_card_regwrite(sdioh_info_t *sd, int func, uint32 regaddr,
+                               int regsize, uint32 data);
+static int bcmspi_card_bytewrite(sdioh_info_t *sd, int func, uint32 regaddr,
+                               uint8 *data);
+static int bcmspi_driver_init(sdioh_info_t *sd);
+static int bcmspi_card_buf(sdioh_info_t *sd, int rw, int func, bool fifo,
+                          uint32 addr, int nbytes, uint32 *data);
+static int bcmspi_card_regread_fixedaddr(sdioh_info_t *sd, int func, uint32 regaddr, int regsize,
+                                 uint32 *data);
+static void bcmspi_cmd_getdstatus(sdioh_info_t *sd, uint32 *dstatus_buffer);
+static int bcmspi_update_stats(sdioh_info_t *sd, uint32 cmd_arg);
+
+/*
+ *  Public entry points & extern's
+ */
+extern sdioh_info_t *
+sdioh_attach(osl_t *osh, void *bar0, uint irq)
+{
+       sdioh_info_t *sd;
+
+       sd_trace(("%s\n", __FUNCTION__));
+       if ((sd = (sdioh_info_t *)MALLOC(osh, sizeof(sdioh_info_t))) == NULL) {
+               sd_err(("%s: out of memory, malloced %d bytes\n", __FUNCTION__, MALLOCED(osh)));
+               return NULL;
+       }
+       bzero((char *)sd, sizeof(sdioh_info_t));
+       sd->osh = osh;
+       if (spi_osinit(sd) != 0) {
+               sd_err(("%s: spi_osinit() failed\n", __FUNCTION__));
+               MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+               return NULL;
+       }
+
+       sd->bar0 = bar0;
+       sd->irq = irq;
+       sd->intr_handler = NULL;
+       sd->intr_handler_arg = NULL;
+       sd->intr_handler_valid = FALSE;
+
+       /* Set defaults */
+       sd->use_client_ints = TRUE;
+       sd->sd_use_dma = FALSE; /* DMA Not supported */
+
+       /* Spi device default is 16bit mode, change to 4 when device is changed to 32bit
+        * mode
+        */
+       sd->wordlen = 2;
+
+       if (!spi_hw_attach(sd)) {
+               sd_err(("%s: spi_hw_attach() failed\n", __FUNCTION__));
+               spi_osfree(sd);
+               MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+               return (NULL);
+       }
+
+       if (bcmspi_driver_init(sd) != SUCCESS) {
+               sd_err(("%s: bcmspi_driver_init() failed()\n", __FUNCTION__));
+               spi_hw_detach(sd);
+               spi_osfree(sd);
+               MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+               return (NULL);
+       }
+
+       if (spi_register_irq(sd, irq) != SUCCESS) {
+               sd_err(("%s: spi_register_irq() failed for irq = %d\n", __FUNCTION__, irq));
+               spi_hw_detach(sd);
+               spi_osfree(sd);
+               MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+               return (NULL);
+       }
+
+       sd_trace(("%s: Done\n", __FUNCTION__));
+
+       return sd;
+}
+
+extern SDIOH_API_RC
+sdioh_detach(osl_t *osh, sdioh_info_t *sd)
+{
+       sd_trace(("%s\n", __FUNCTION__));
+       if (sd) {
+               sd_err(("%s: detaching from hardware\n", __FUNCTION__));
+               spi_free_irq(sd->irq, sd);
+               spi_hw_detach(sd);
+               spi_osfree(sd);
+               MFREE(sd->osh, sd, sizeof(sdioh_info_t));
+       }
+       return SDIOH_API_RC_SUCCESS;
+}
+
+/* Configure callback to client when we recieve client interrupt */
+extern SDIOH_API_RC
+sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
+{
+       sd_trace(("%s: Entering\n", __FUNCTION__));
+       sd->intr_handler = fn;
+       sd->intr_handler_arg = argh;
+       sd->intr_handler_valid = TRUE;
+       return SDIOH_API_RC_SUCCESS;
+}
+
+extern SDIOH_API_RC
+sdioh_interrupt_deregister(sdioh_info_t *sd)
+{
+       sd_trace(("%s: Entering\n", __FUNCTION__));
+       sd->intr_handler_valid = FALSE;
+       sd->intr_handler = NULL;
+       sd->intr_handler_arg = NULL;
+       return SDIOH_API_RC_SUCCESS;
+}
+
+extern SDIOH_API_RC
+sdioh_interrupt_query(sdioh_info_t *sd, bool *onoff)
+{
+       sd_trace(("%s: Entering\n", __FUNCTION__));
+       *onoff = sd->client_intr_enabled;
+       return SDIOH_API_RC_SUCCESS;
+}
+
+#if defined(DHD_DEBUG)
+extern bool
+sdioh_interrupt_pending(sdioh_info_t *sd)
+{
+       return 0;
+}
+#endif
+
+extern SDIOH_API_RC
+sdioh_query_device(sdioh_info_t *sd)
+{
+       /* Return a BRCM ID appropriate to the dongle class */
+       return (sd->num_funcs > 1) ? BCM4329_D11NDUAL_ID : BCM4318_D11G_ID;
+}
+
+/* Provide dstatus bits of spi-transaction for dhd layers. */
+extern uint32
+sdioh_get_dstatus(sdioh_info_t *sd)
+{
+       return sd->card_dstatus;
+}
+
+extern void
+sdioh_chipinfo(sdioh_info_t *sd, uint32 chip, uint32 chiprev)
+{
+       sd->chip = chip;
+       sd->chiprev = chiprev;
+}
+
+extern void
+sdioh_dwordmode(sdioh_info_t *sd, bool set)
+{
+       uint8 reg = 0;
+       int status;
+
+       if ((status = sdioh_request_byte(sd, SDIOH_READ, SPI_FUNC_0, SPID_STATUS_ENABLE, &reg)) !=
+            SUCCESS) {
+               sd_err(("%s: Failed to set dwordmode in gSPI\n", __FUNCTION__));
+               return;
+       }
+
+       if (set) {
+               reg |= DWORD_PKT_LEN_EN;
+               sd->dwordmode = TRUE;
+               sd->client_block_size[SPI_FUNC_2] = 4096; /* h2spi's limit is 4KB, we support 8KB */
+       } else {
+               reg &= ~DWORD_PKT_LEN_EN;
+               sd->dwordmode = FALSE;
+               sd->client_block_size[SPI_FUNC_2] = 2048;
+       }
+
+       if ((status = sdioh_request_byte(sd, SDIOH_WRITE, SPI_FUNC_0, SPID_STATUS_ENABLE, &reg)) !=
+            SUCCESS) {
+               sd_err(("%s: Failed to set dwordmode in gSPI\n", __FUNCTION__));
+               return;
+       }
+}
+
+
+uint
+sdioh_query_iofnum(sdioh_info_t *sd)
+{
+       return sd->num_funcs;
+}
+
+/* IOVar table */
+enum {
+       IOV_MSGLEVEL = 1,
+       IOV_BLOCKMODE,
+       IOV_BLOCKSIZE,
+       IOV_DMA,
+       IOV_USEINTS,
+       IOV_NUMINTS,
+       IOV_NUMLOCALINTS,
+       IOV_HOSTREG,
+       IOV_DEVREG,
+       IOV_DIVISOR,
+       IOV_SDMODE,
+       IOV_HISPEED,
+       IOV_HCIREGS,
+       IOV_POWER,
+       IOV_CLOCK,
+       IOV_SPIERRSTATS,
+       IOV_RESP_DELAY_ALL
+};
+
+const bcm_iovar_t sdioh_iovars[] = {
+       {"sd_msglevel", IOV_MSGLEVEL,   0,      IOVT_UINT32,    0 },
+       {"sd_blocksize", IOV_BLOCKSIZE, 0,      IOVT_UINT32,    0 }, /* ((fn << 16) | size) */
+       {"sd_dma",      IOV_DMA,        0,      IOVT_BOOL,      0 },
+       {"sd_ints",     IOV_USEINTS,    0,      IOVT_BOOL,      0 },
+       {"sd_numints",  IOV_NUMINTS,    0,      IOVT_UINT32,    0 },
+       {"sd_numlocalints", IOV_NUMLOCALINTS, 0, IOVT_UINT32,   0 },
+       {"sd_hostreg",  IOV_HOSTREG,    0,      IOVT_BUFFER,    sizeof(sdreg_t) },
+       {"sd_devreg",   IOV_DEVREG,     0,      IOVT_BUFFER,    sizeof(sdreg_t) },
+       {"sd_divisor",  IOV_DIVISOR,    0,      IOVT_UINT32,    0 },
+       {"sd_power",    IOV_POWER,      0,      IOVT_UINT32,    0 },
+       {"sd_clock",    IOV_CLOCK,      0,      IOVT_UINT32,    0 },
+       {"sd_mode",     IOV_SDMODE,     0,      IOVT_UINT32,    100},
+       {"sd_highspeed",        IOV_HISPEED,    0,      IOVT_UINT32,    0},
+       {"spi_errstats", IOV_SPIERRSTATS, 0, IOVT_BUFFER, sizeof(struct spierrstats_t) },
+       {"spi_respdelay",       IOV_RESP_DELAY_ALL,     0,      IOVT_BOOL,      0 },
+       {NULL, 0, 0, 0, 0 }
+};
+
+int
+sdioh_iovar_op(sdioh_info_t *si, const char *name,
+               void *params, int plen, void *arg, int len, bool set)
+{
+       const bcm_iovar_t *vi = NULL;
+       int bcmerror = 0;
+       int val_size;
+       int32 int_val = 0;
+       bool bool_val;
+       uint32 actionid;
+/*
+       sdioh_regs_t *regs;
+*/
+
+       ASSERT(name);
+       ASSERT(len >= 0);
+
+       /* Get must have return space; Set does not take qualifiers */
+       ASSERT(set || (arg && len));
+       ASSERT(!set || (!params && !plen));
+
+       sd_trace(("%s: Enter (%s %s)\n", __FUNCTION__, (set ? "set" : "get"), name));
+
+       if ((vi = bcm_iovar_lookup(sdioh_iovars, name)) == NULL) {
+               bcmerror = BCME_UNSUPPORTED;
+               goto exit;
+       }
+
+       if ((bcmerror = bcm_iovar_lencheck(vi, arg, len, set)) != 0)
+               goto exit;
+
+       /* Set up params so get and set can share the convenience variables */
+       if (params == NULL) {
+               params = arg;
+               plen = len;
+       }
+
+       if (vi->type == IOVT_VOID)
+               val_size = 0;
+       else if (vi->type == IOVT_BUFFER)
+               val_size = len;
+       else
+               val_size = sizeof(int);
+
+       if (plen >= (int)sizeof(int_val))
+               bcopy(params, &int_val, sizeof(int_val));
+
+       bool_val = (int_val != 0) ? TRUE : FALSE;
+
+       actionid = set ? IOV_SVAL(vi->varid) : IOV_GVAL(vi->varid);
+       switch (actionid) {
+       case IOV_GVAL(IOV_MSGLEVEL):
+               int_val = (int32)sd_msglevel;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_MSGLEVEL):
+               sd_msglevel = int_val;
+               break;
+
+       case IOV_GVAL(IOV_BLOCKSIZE):
+               if ((uint32)int_val > si->num_funcs) {
+                       bcmerror = BCME_BADARG;
+                       break;
+               }
+               int_val = (int32)si->client_block_size[int_val];
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_GVAL(IOV_DMA):
+               int_val = (int32)si->sd_use_dma;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_DMA):
+               si->sd_use_dma = (bool)int_val;
+               break;
+
+       case IOV_GVAL(IOV_USEINTS):
+               int_val = (int32)si->use_client_ints;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_USEINTS):
+               break;
+
+       case IOV_GVAL(IOV_DIVISOR):
+               int_val = (uint32)sd_divisor;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_DIVISOR):
+               sd_divisor = int_val;
+               if (!spi_start_clock(si, (uint16)sd_divisor)) {
+                       sd_err(("%s: set clock failed\n", __FUNCTION__));
+                       bcmerror = BCME_ERROR;
+               }
+               break;
+
+       case IOV_GVAL(IOV_POWER):
+               int_val = (uint32)sd_power;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_POWER):
+               sd_power = int_val;
+               break;
+
+       case IOV_GVAL(IOV_CLOCK):
+               int_val = (uint32)sd_clock;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_CLOCK):
+               sd_clock = int_val;
+               break;
+
+       case IOV_GVAL(IOV_SDMODE):
+               int_val = (uint32)sd_sdmode;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_SDMODE):
+               sd_sdmode = int_val;
+               break;
+
+       case IOV_GVAL(IOV_HISPEED):
+               int_val = (uint32)sd_hiok;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_HISPEED):
+               sd_hiok = int_val;
+
+               if (!bcmspi_set_highspeed_mode(si, (bool)sd_hiok)) {
+                       sd_err(("%s: Failed changing highspeed mode to %d.\n",
+                               __FUNCTION__, sd_hiok));
+                       bcmerror = BCME_ERROR;
+                       return ERROR;
+               }
+               break;
+
+       case IOV_GVAL(IOV_NUMINTS):
+               int_val = (int32)si->intrcount;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_GVAL(IOV_NUMLOCALINTS):
+               int_val = (int32)si->local_intrcount;
+               bcopy(&int_val, arg, val_size);
+               break;
+       case IOV_GVAL(IOV_DEVREG):
+       {
+               sdreg_t *sd_ptr = (sdreg_t *)params;
+               uint8 data;
+
+               if (sdioh_cfg_read(si, sd_ptr->func, sd_ptr->offset, &data)) {
+                       bcmerror = BCME_SDIO_ERROR;
+                       break;
+               }
+
+               int_val = (int)data;
+               bcopy(&int_val, arg, sizeof(int_val));
+               break;
+       }
+
+       case IOV_SVAL(IOV_DEVREG):
+       {
+               sdreg_t *sd_ptr = (sdreg_t *)params;
+               uint8 data = (uint8)sd_ptr->value;
+
+               if (sdioh_cfg_write(si, sd_ptr->func, sd_ptr->offset, &data)) {
+                       bcmerror = BCME_SDIO_ERROR;
+                       break;
+               }
+               break;
+       }
+
+
+       case IOV_GVAL(IOV_SPIERRSTATS):
+       {
+               bcopy(&si->spierrstats, arg, sizeof(struct spierrstats_t));
+               break;
+       }
+
+       case IOV_SVAL(IOV_SPIERRSTATS):
+       {
+               bzero(&si->spierrstats, sizeof(struct spierrstats_t));
+               break;
+       }
+
+       case IOV_GVAL(IOV_RESP_DELAY_ALL):
+               int_val = (int32)si->resp_delay_all;
+               bcopy(&int_val, arg, val_size);
+               break;
+
+       case IOV_SVAL(IOV_RESP_DELAY_ALL):
+               si->resp_delay_all = (bool)int_val;
+               int_val = STATUS_ENABLE|INTR_WITH_STATUS;
+               if (si->resp_delay_all)
+                       int_val |= RESP_DELAY_ALL;
+               else {
+                       if (bcmspi_card_regwrite(si, SPI_FUNC_0, SPID_RESPONSE_DELAY, 1,
+                            F1_RESPONSE_DELAY) != SUCCESS) {
+                               sd_err(("%s: Unable to set response delay.\n", __FUNCTION__));
+                               bcmerror = BCME_SDIO_ERROR;
+                               break;
+                       }
+               }
+
+               if (bcmspi_card_regwrite(si, SPI_FUNC_0, SPID_STATUS_ENABLE, 1, int_val)
+                    != SUCCESS) {
+                       sd_err(("%s: Unable to set response delay.\n", __FUNCTION__));
+                       bcmerror = BCME_SDIO_ERROR;
+                       break;
+               }
+               break;
+
+       default:
+               bcmerror = BCME_UNSUPPORTED;
+               break;
+       }
+exit:
+
+       return bcmerror;
+}
+
+extern SDIOH_API_RC
+sdioh_cfg_read(sdioh_info_t *sd, uint fnc_num, uint32 addr, uint8 *data)
+{
+       SDIOH_API_RC status;
+       /* No lock needed since sdioh_request_byte does locking */
+       status = sdioh_request_byte(sd, SDIOH_READ, fnc_num, addr, data);
+       return status;
+}
+
+extern SDIOH_API_RC
+sdioh_cfg_write(sdioh_info_t *sd, uint fnc_num, uint32 addr, uint8 *data)
+{
+       /* No lock needed since sdioh_request_byte does locking */
+       SDIOH_API_RC status;
+
+       if ((fnc_num == SPI_FUNC_1) && (addr == SBSDIO_FUNC1_FRAMECTRL)) {
+               uint8 dummy_data;
+               status = sdioh_cfg_read(sd, fnc_num, addr, &dummy_data);
+               if (status) {
+                       sd_err(("sdioh_cfg_read() failed.\n"));
+                       return status;
+               }
+       }
+
+       status = sdioh_request_byte(sd, SDIOH_WRITE, fnc_num, addr, data);
+       return status;
+}
+
+extern SDIOH_API_RC
+sdioh_cis_read(sdioh_info_t *sd, uint func, uint8 *cisd, uint32 length)
+{
+       uint32 count;
+       int offset;
+       uint32 cis_byte;
+       uint16 *cis = (uint16 *)cisd;
+       uint bar0 = SI_ENUM_BASE;
+       int status;
+       uint8 data;
+
+       sd_trace(("%s: Func %d\n", __FUNCTION__, func));
+
+       spi_lock(sd);
+
+       /* Set sb window address to 0x18000000 */
+       data = (bar0 >> 8) & SBSDIO_SBADDRLOW_MASK;
+       status = bcmspi_card_bytewrite(sd, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, &data);
+       if (status == SUCCESS) {
+               data = (bar0 >> 16) & SBSDIO_SBADDRMID_MASK;
+               status = bcmspi_card_bytewrite(sd, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, &data);
+       } else {
+               sd_err(("%s: Unable to set sb-addr-windows\n", __FUNCTION__));
+               spi_unlock(sd);
+               return (BCME_ERROR);
+       }
+       if (status == SUCCESS) {
+               data = (bar0 >> 24) & SBSDIO_SBADDRHIGH_MASK;
+               status = bcmspi_card_bytewrite(sd, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, &data);
+       } else {
+               sd_err(("%s: Unable to set sb-addr-windows\n", __FUNCTION__));
+               spi_unlock(sd);
+               return (BCME_ERROR);
+       }
+
+       offset =  CC_OTP; /* OTP offset in chipcommon. */
+       for (count = 0; count < length/2; count++) {
+               if (bcmspi_card_regread (sd, SDIO_FUNC_1, offset, 2, &cis_byte) < 0) {
+                       sd_err(("%s: regread failed: Can't read CIS\n", __FUNCTION__));
+                       spi_unlock(sd);
+                       return (BCME_ERROR);
+               }
+
+               *cis = (uint16)cis_byte;
+               cis++;
+               offset += 2;
+       }
+
+       spi_unlock(sd);
+
+       return (BCME_OK);
+}
+
+extern SDIOH_API_RC
+sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr, uint8 *byte)
+{
+       int status;
+       uint32 cmd_arg;
+       uint32 dstatus;
+       uint32 data = (uint32)(*byte);
+
+       spi_lock(sd);
+
+       cmd_arg = 0;
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);       /* Incremental access */
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, rw == SDIOH_READ ? 0 : 1);
+       cmd_arg = SFIELD(cmd_arg, SPI_LEN, 1);
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+       sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, rw, func,
+                regaddr, data));
+
+       if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma,
+                                     cmd_arg, &data, 1)) != SUCCESS) {
+               spi_unlock(sd);
+               return status;
+       }
+
+       if (rw == SDIOH_READ)
+               *byte = (uint8)data;
+
+       bcmspi_cmd_getdstatus(sd, &dstatus);
+       if (dstatus)
+               sd_trace(("dstatus =0x%x\n", dstatus));
+
+       spi_unlock(sd);
+       return SDIOH_API_RC_SUCCESS;
+}
+
+extern SDIOH_API_RC
+sdioh_request_word(sdioh_info_t *sd, uint cmd_type, uint rw, uint func, uint addr,
+                   uint32 *word, uint nbytes)
+{
+       int status;
+
+       spi_lock(sd);
+
+       if (rw == SDIOH_READ)
+               status = bcmspi_card_regread(sd, func, addr, nbytes, word);
+       else
+               status = bcmspi_card_regwrite(sd, func, addr, nbytes, *word);
+
+       spi_unlock(sd);
+       return (status == SUCCESS ?  SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
+}
+
+extern SDIOH_API_RC
+sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint rw, uint func,
+                     uint addr, uint reg_width, uint buflen_u, uint8 *buffer, void *pkt)
+{
+       int len;
+       int buflen = (int)buflen_u;
+       bool fifo = (fix_inc == SDIOH_DATA_FIX);
+
+       spi_lock(sd);
+
+       ASSERT(reg_width == 4);
+       ASSERT(buflen_u < (1 << 30));
+       ASSERT(sd->client_block_size[func]);
+
+       sd_data(("%s: %c len %d r_cnt %d t_cnt %d, pkt @0x%p\n",
+                __FUNCTION__, rw == SDIOH_READ ? 'R' : 'W',
+                buflen_u, sd->r_cnt, sd->t_cnt, pkt));
+
+       /* Break buffer down into blocksize chunks. */
+       while (buflen > 0) {
+               len = MIN(sd->client_block_size[func], buflen);
+               if (bcmspi_card_buf(sd, rw, func, fifo, addr, len, (uint32 *)buffer) != SUCCESS) {
+                       sd_err(("%s: bcmspi_card_buf %s failed\n",
+                               __FUNCTION__, rw == SDIOH_READ ? "Read" : "Write"));
+                       spi_unlock(sd);
+                       return SDIOH_API_RC_FAIL;
+               }
+               buffer += len;
+               buflen -= len;
+               if (!fifo)
+                       addr += len;
+       }
+       spi_unlock(sd);
+       return SDIOH_API_RC_SUCCESS;
+}
+
+/* This function allows write to gspi bus when another rd/wr function is deep down the call stack.
+ * Its main aim is to have simpler spi writes rather than recursive writes.
+ * e.g. When there is a need to program response delay on the fly after detecting the SPI-func
+ * this call will allow to program the response delay.
+ */
+static int
+bcmspi_card_byterewrite(sdioh_info_t *sd, int func, uint32 regaddr, uint8 byte)
+{
+       uint32 cmd_arg;
+       uint32 datalen = 1;
+       uint32 hostlen;
+
+       cmd_arg = 0;
+
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 1);
+       cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);       /* Incremental access */
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+       cmd_arg = SFIELD(cmd_arg, SPI_LEN, datalen);
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+
+
+       /* Set up and issue the SPI command.  MSByte goes out on bus first.  Increase datalen
+        * according to the wordlen mode(16/32bit) the device is in.
+        */
+       ASSERT(sd->wordlen == 4 || sd->wordlen == 2);
+       datalen = ROUNDUP(datalen, sd->wordlen);
+
+       /* Start by copying command in the spi-outbuffer */
+       if (sd->wordlen == 4) { /* 32bit spid */
+               *(uint32 *)spi_outbuf2 = bcmswap32(cmd_arg);
+               if (datalen & 0x3)
+                       datalen += (4 - (datalen & 0x3));
+       } else if (sd->wordlen == 2) { /* 16bit spid */
+               *(uint16 *)spi_outbuf2 = bcmswap16(cmd_arg & 0xffff);
+               *(uint16 *)&spi_outbuf2[2] = bcmswap16((cmd_arg & 0xffff0000) >> 16);
+               if (datalen & 0x1)
+                       datalen++;
+       } else {
+               sd_err(("%s: Host is %d bit spid, could not create SPI command.\n",
+                       __FUNCTION__, 8 * sd->wordlen));
+               return ERROR;
+       }
+
+       /* for Write, put the data into the output buffer  */
+       if (datalen != 0) {
+                       if (sd->wordlen == 4) { /* 32bit spid */
+                               *(uint32 *)&spi_outbuf2[CMDLEN] = bcmswap32(byte);
+                       } else if (sd->wordlen == 2) { /* 16bit spid */
+                               *(uint16 *)&spi_outbuf2[CMDLEN] = bcmswap16(byte & 0xffff);
+                               *(uint16 *)&spi_outbuf2[CMDLEN + 2] =
+                                       bcmswap16((byte & 0xffff0000) >> 16);
+                       }
+       }
+
+       /* +4 for cmd, +4 for dstatus */
+       hostlen = datalen + 8;
+       hostlen += (4 - (hostlen & 0x3));
+       spi_sendrecv(sd, spi_outbuf2, spi_inbuf2, hostlen);
+
+       /* Last 4bytes are dstatus.  Device is configured to return status bits. */
+       if (sd->wordlen == 4) { /* 32bit spid */
+               sd->card_dstatus = bcmswap32(*(uint32 *)&spi_inbuf2[datalen + CMDLEN ]);
+       } else if (sd->wordlen == 2) { /* 16bit spid */
+               sd->card_dstatus = (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN ]) |
+                                  (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN + 2]) << 16));
+       } else {
+               sd_err(("%s: Host is %d bit machine, could not read SPI dstatus.\n",
+                       __FUNCTION__, 8 * sd->wordlen));
+               return ERROR;
+       }
+
+       if (sd->card_dstatus)
+               sd_trace(("dstatus after byte rewrite = 0x%x\n", sd->card_dstatus));
+
+       return (BCME_OK);
+}
+
+/* Program the response delay corresponding to the spi function */
+static int
+bcmspi_prog_resp_delay(sdioh_info_t *sd, int func, uint8 resp_delay)
+{
+       if (sd->resp_delay_all == FALSE)
+               return (BCME_OK);
+
+       if (sd->prev_fun == func)
+               return (BCME_OK);
+
+       if (F0_RESPONSE_DELAY == F1_RESPONSE_DELAY)
+               return (BCME_OK);
+
+       bcmspi_card_byterewrite(sd, SPI_FUNC_0, SPID_RESPONSE_DELAY, resp_delay);
+
+       /* Remember function for which to avoid reprogramming resp-delay in next iteration */
+       sd->prev_fun = func;
+
+       return (BCME_OK);
+
+}
+
+#define GSPI_RESYNC_PATTERN    0x0
+
+/* A resync pattern is a 32bit MOSI line with all zeros. Its a special command in gSPI.
+ * It resets the spi-bkplane logic so that all F1 related ping-pong buffer logic is
+ * synchronised and all queued resuests are cancelled.
+ */
+static int
+bcmspi_resync_f1(sdioh_info_t *sd)
+{
+       uint32 cmd_arg = GSPI_RESYNC_PATTERN, data = 0, datalen = 0;
+
+
+       /* Set up and issue the SPI command.  MSByte goes out on bus first.  Increase datalen
+        * according to the wordlen mode(16/32bit) the device is in.
+        */
+       ASSERT(sd->wordlen == 4 || sd->wordlen == 2);
+       datalen = ROUNDUP(datalen, sd->wordlen);
+
+       /* Start by copying command in the spi-outbuffer */
+       *(uint32 *)spi_outbuf2 = cmd_arg;
+
+       /* for Write, put the data into the output buffer  */
+       *(uint32 *)&spi_outbuf2[CMDLEN] = data;
+
+       /* +4 for cmd, +4 for dstatus */
+       spi_sendrecv(sd, spi_outbuf2, spi_inbuf2, datalen + 8);
+
+       /* Last 4bytes are dstatus.  Device is configured to return status bits. */
+       if (sd->wordlen == 4) { /* 32bit spid */
+               sd->card_dstatus = bcmswap32(*(uint32 *)&spi_inbuf2[datalen + CMDLEN ]);
+       } else if (sd->wordlen == 2) { /* 16bit spid */
+               sd->card_dstatus = (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN ]) |
+                                  (bcmswap16(*(uint16 *)&spi_inbuf2[datalen + CMDLEN + 2]) << 16));
+       } else {
+               sd_err(("%s: Host is %d bit machine, could not read SPI dstatus.\n",
+                       __FUNCTION__, 8 * sd->wordlen));
+               return ERROR;
+       }
+
+       if (sd->card_dstatus)
+               sd_trace(("dstatus after resync pattern write = 0x%x\n", sd->card_dstatus));
+
+       return (BCME_OK);
+}
+
+uint32 dstatus_count = 0;
+
+static int
+bcmspi_update_stats(sdioh_info_t *sd, uint32 cmd_arg)
+{
+       uint32 dstatus = sd->card_dstatus;
+       struct spierrstats_t *spierrstats = &sd->spierrstats;
+       int err = SUCCESS;
+
+       sd_trace(("cmd = 0x%x, dstatus = 0x%x\n", cmd_arg, dstatus));
+
+       /* Store dstatus of last few gSPI transactions */
+       spierrstats->dstatus[dstatus_count % NUM_PREV_TRANSACTIONS] = dstatus;
+       spierrstats->spicmd[dstatus_count % NUM_PREV_TRANSACTIONS] = cmd_arg;
+       dstatus_count++;
+
+       if (sd->card_init_done == FALSE)
+               return err;
+
+       if (dstatus & STATUS_DATA_NOT_AVAILABLE) {
+               spierrstats->dna++;
+               sd_trace(("Read data not available on F1 addr = 0x%x\n",
+                       GFIELD(cmd_arg, SPI_REG_ADDR)));
+               /* Clear dna bit */
+               bcmspi_card_byterewrite(sd, SPI_FUNC_0, SPID_INTR_REG, DATA_UNAVAILABLE);
+       }
+
+       if (dstatus & STATUS_UNDERFLOW) {
+               spierrstats->rdunderflow++;
+               sd_err(("FIFO underflow happened due to current F2 read command.\n"));
+       }
+
+       if (dstatus & STATUS_OVERFLOW) {
+               spierrstats->wroverflow++;
+               sd_err(("FIFO overflow happened due to current (F1/F2) write command.\n"));
+               if ((sd->chip == BCM4329_CHIP_ID) && (sd->chiprev == 0)) {
+                       bcmspi_card_byterewrite(sd, SPI_FUNC_0, SPID_INTR_REG, F1_OVERFLOW);
+                       bcmspi_resync_f1(sd);
+                       sd_err(("Recovering from F1 FIFO overflow.\n"));
+               } else {
+                       err = ERROR_OF;
+               }
+       }
+
+       if (dstatus & STATUS_F2_INTR) {
+               spierrstats->f2interrupt++;
+               sd_trace(("Interrupt from F2.  SW should clear corresponding IntStatus bits\n"));
+       }
+
+       if (dstatus & STATUS_F3_INTR) {
+               spierrstats->f3interrupt++;
+               sd_err(("Interrupt from F3.  SW should clear corresponding IntStatus bits\n"));
+       }
+
+       if (dstatus & STATUS_HOST_CMD_DATA_ERR) {
+               spierrstats->hostcmddataerr++;
+               sd_err(("Error in CMD or Host data, detected by CRC/Checksum (optional)\n"));
+       }
+
+       if (dstatus & STATUS_F2_PKT_AVAILABLE) {
+               spierrstats->f2pktavailable++;
+               sd_trace(("Packet is available/ready in F2 TX FIFO\n"));
+               sd_trace(("Packet length = %d\n", sd->dwordmode ?
+                        ((dstatus & STATUS_F2_PKT_LEN_MASK) >> (STATUS_F2_PKT_LEN_SHIFT - 2)) :
+                        ((dstatus & STATUS_F2_PKT_LEN_MASK) >> STATUS_F2_PKT_LEN_SHIFT)));
+       }
+
+       if (dstatus & STATUS_F3_PKT_AVAILABLE) {
+               spierrstats->f3pktavailable++;
+               sd_err(("Packet is available/ready in F3 TX FIFO\n"));
+               sd_err(("Packet length = %d\n",
+                       (dstatus & STATUS_F3_PKT_LEN_MASK) >> STATUS_F3_PKT_LEN_SHIFT));
+       }
+
+       return err;
+}
+
+extern int
+sdioh_abort(sdioh_info_t *sd, uint func)
+{
+       return 0;
+}
+
+int
+sdioh_start(sdioh_info_t *sd, int stage)
+{
+       return SUCCESS;
+}
+
+int
+sdioh_stop(sdioh_info_t *sd)
+{
+       return SUCCESS;
+}
+
+
+
+/*
+ * Private/Static work routines
+ */
+static int
+bcmspi_host_init(sdioh_info_t *sd)
+{
+
+       /* Default power on mode */
+       sd->sd_mode = SDIOH_MODE_SPI;
+       sd->polled_mode = TRUE;
+       sd->host_init_done = TRUE;
+       sd->card_init_done = FALSE;
+       sd->adapter_slot = 1;
+
+       return (SUCCESS);
+}
+
+static int
+get_client_blocksize(sdioh_info_t *sd)
+{
+       uint32 regdata[2];
+       int status;
+
+       /* Find F1/F2/F3 max packet size */
+       if ((status = bcmspi_card_regread(sd, 0, SPID_F1_INFO_REG,
+                                        8, regdata)) != SUCCESS) {
+               return status;
+       }
+
+       sd_trace(("pkt_size regdata[0] = 0x%x, regdata[1] = 0x%x\n",
+               regdata[0], regdata[1]));
+
+       sd->client_block_size[1] = (regdata[0] & F1_MAX_PKT_SIZE) >> 2;
+       sd_trace(("Func1 blocksize = %d\n", sd->client_block_size[1]));
+       ASSERT(sd->client_block_size[1] == BLOCK_SIZE_F1);
+
+       sd->client_block_size[2] = ((regdata[0] >> 16) & F2_MAX_PKT_SIZE) >> 2;
+       sd_trace(("Func2 blocksize = %d\n", sd->client_block_size[2]));
+       ASSERT(sd->client_block_size[2] == BLOCK_SIZE_F2);
+
+       sd->client_block_size[3] = (regdata[1] & F3_MAX_PKT_SIZE) >> 2;
+       sd_trace(("Func3 blocksize = %d\n", sd->client_block_size[3]));
+       ASSERT(sd->client_block_size[3] == BLOCK_SIZE_F3);
+
+       return 0;
+}
+
+static int
+bcmspi_client_init(sdioh_info_t *sd)
+{
+       uint32  status_en_reg = 0;
+       sd_trace(("%s: Powering up slot %d\n", __FUNCTION__, sd->adapter_slot));
+
+#ifdef HSMODE
+       if (!spi_start_clock(sd, (uint16)sd_divisor)) {
+               sd_err(("spi_start_clock failed\n"));
+               return ERROR;
+       }
+#else
+       /* Start at ~400KHz clock rate for initialization */
+       if (!spi_start_clock(sd, 128)) {
+               sd_err(("spi_start_clock failed\n"));
+               return ERROR;
+       }
+#endif /* HSMODE */
+
+       if (!bcmspi_host_device_init_adapt(sd)) {
+               sd_err(("bcmspi_host_device_init_adapt failed\n"));
+               return ERROR;
+       }
+
+       if (!bcmspi_test_card(sd)) {
+               sd_err(("bcmspi_test_card failed\n"));
+               return ERROR;
+       }
+
+       sd->num_funcs = SPI_MAX_IOFUNCS;
+
+       get_client_blocksize(sd);
+
+       /* Apply resync pattern cmd with all zeros to reset spi-bkplane F1 logic */
+       bcmspi_resync_f1(sd);
+
+       sd->dwordmode = FALSE;
+
+       bcmspi_card_regread(sd, 0, SPID_STATUS_ENABLE, 1, &status_en_reg);
+
+       sd_trace(("%s: Enabling interrupt with dstatus \n", __FUNCTION__));
+       status_en_reg |= INTR_WITH_STATUS;
+
+
+       if (bcmspi_card_regwrite(sd, SPI_FUNC_0, SPID_STATUS_ENABLE, 1,
+           status_en_reg & 0xff) != SUCCESS) {
+               sd_err(("%s: Unable to set response delay for all fun's.\n", __FUNCTION__));
+               return ERROR;
+       }
+
+
+#ifndef HSMODE
+       /* After configuring for High-Speed mode, set the desired clock rate. */
+       if (!spi_start_clock(sd, 4)) {
+               sd_err(("spi_start_clock failed\n"));
+               return ERROR;
+       }
+#endif /* HSMODE */
+
+       sd->card_init_done = TRUE;
+
+
+       return SUCCESS;
+}
+
+static int
+bcmspi_set_highspeed_mode(sdioh_info_t *sd, bool hsmode)
+{
+       uint32 regdata;
+       int status;
+
+       if ((status = bcmspi_card_regread(sd, 0, SPID_CONFIG,
+                                        4, &regdata)) != SUCCESS)
+               return status;
+
+       sd_trace(("In %s spih-ctrl = 0x%x \n", __FUNCTION__, regdata));
+
+
+       if (hsmode == TRUE) {
+               sd_trace(("Attempting to enable High-Speed mode.\n"));
+
+               if (regdata & HIGH_SPEED_MODE) {
+                       sd_trace(("Device is already in High-Speed mode.\n"));
+                       return status;
+               } else {
+                       regdata |= HIGH_SPEED_MODE;
+                       sd_trace(("Writing %08x to device at %08x\n", regdata, SPID_CONFIG));
+                       if ((status = bcmspi_card_regwrite(sd, 0, SPID_CONFIG,
+                                                         4, regdata)) != SUCCESS) {
+                               return status;
+                       }
+               }
+       } else {
+               sd_trace(("Attempting to disable High-Speed mode.\n"));
+
+               if (regdata & HIGH_SPEED_MODE) {
+                       regdata &= ~HIGH_SPEED_MODE;
+                       sd_trace(("Writing %08x to device at %08x\n", regdata, SPID_CONFIG));
+                       if ((status = bcmspi_card_regwrite(sd, 0, SPID_CONFIG,
+                                                         4, regdata)) != SUCCESS)
+                               return status;
+               }
+                else {
+                       sd_trace(("Device is already in Low-Speed mode.\n"));
+                       return status;
+               }
+       }
+
+       spi_controller_highspeed_mode(sd, hsmode);
+
+       return TRUE;
+}
+
+#define bcmspi_find_curr_mode(sd) { \
+       sd->wordlen = 2; \
+       status = bcmspi_card_regread_fixedaddr(sd, 0, SPID_TEST_READ, 4, &regdata); \
+       regdata &= 0xff; \
+       if ((regdata == 0xad) || (regdata == 0x5b) || \
+           (regdata == 0x5d) || (regdata == 0x5a)) \
+               break; \
+       sd->wordlen = 4; \
+       status = bcmspi_card_regread_fixedaddr(sd, 0, SPID_TEST_READ, 4, &regdata); \
+       regdata &= 0xff; \
+       if ((regdata == 0xad) || (regdata == 0x5b) || \
+           (regdata == 0x5d) || (regdata == 0x5a)) \
+               break; \
+       sd_trace(("Silicon testability issue: regdata = 0x%x." \
+                 " Expected 0xad, 0x5a, 0x5b or 0x5d.\n", regdata));   \
+       OSL_DELAY(100000); \
+}
+
+#define INIT_ADAPT_LOOP                100
+
+/* Adapt clock-phase-speed-bitwidth between host and device */
+static bool
+bcmspi_host_device_init_adapt(sdioh_info_t *sd)
+{
+       uint32 wrregdata, regdata = 0;
+       int status;
+       int i;
+
+       /* Due to a silicon testability issue, the first command from the Host
+        * to the device will get corrupted (first bit will be lost). So the
+        * Host should poll the device with a safe read request. ie: The Host
+        * should try to read F0 addr 0x14 using the Fixed address mode
+        * (This will prevent a unintended write command to be detected by device)
+        */
+       for (i = 0; i < INIT_ADAPT_LOOP; i++) {
+               /* If device was not power-cycled it will stay in 32bit mode with
+                * response-delay-all bit set.  Alternate the iteration so that
+                * read either with or without response-delay for F0 to succeed.
+                */
+               bcmspi_find_curr_mode(sd);
+               sd->resp_delay_all = (i & 0x1) ? TRUE : FALSE;
+
+               bcmspi_find_curr_mode(sd);
+               sd->dwordmode = TRUE;
+
+               bcmspi_find_curr_mode(sd);
+               sd->dwordmode = FALSE;
+       }
+
+       /* Bail out, device not detected */
+       if (i == INIT_ADAPT_LOOP)
+               return FALSE;
+
+       /* Softreset the spid logic */
+       if ((sd->dwordmode) || (sd->wordlen == 4)) {
+               bcmspi_card_regwrite(sd, 0, SPID_RESET_BP, 1, RESET_ON_WLAN_BP_RESET|RESET_SPI);
+               bcmspi_card_regread(sd, 0, SPID_RESET_BP, 1, &regdata);
+               sd_trace(("reset reg read = 0x%x\n", regdata));
+               sd_trace(("dwordmode = %d, wordlen = %d, resp_delay_all = %d\n", sd->dwordmode,
+                      sd->wordlen, sd->resp_delay_all));
+               /* Restore default state after softreset */
+               sd->wordlen = 2;
+               sd->dwordmode = FALSE;
+       }
+
+       if (sd->wordlen == 4) {
+               if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, &regdata)) !=
+                    SUCCESS)
+                               return FALSE;
+               if (regdata == TEST_RO_DATA_32BIT_LE) {
+                       sd_trace(("Spid is already in 32bit LE mode. Value read = 0x%x\n",
+                                 regdata));
+                       sd_trace(("Spid power was left on.\n"));
+               } else {
+                       sd_err(("Spid power was left on but signature read failed."
+                               " Value read = 0x%x\n", regdata));
+                       return FALSE;
+               }
+       } else {
+               sd->wordlen = 2;
+
+#define CTRL_REG_DEFAULT       0x00010430 /* according to the host m/c */
+
+               wrregdata = (CTRL_REG_DEFAULT);
+               sd->resp_delay_all = TRUE;
+               if (sd->resp_delay_all == TRUE) {
+                       /* Enable response delay for all */
+                       wrregdata |= (RESP_DELAY_ALL << 16);
+                       /* Program response delay value */
+                       wrregdata &= 0xffff00ff;
+                       wrregdata |= (F1_RESPONSE_DELAY << 8);
+                       sd->prev_fun = SPI_FUNC_1;
+                       bcmspi_card_regwrite(sd, 0, SPID_CONFIG, 4, wrregdata);
+               }
+
+               if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, &regdata)) != SUCCESS)
+                       return FALSE;
+               sd_trace(("(we are still in 16bit mode) 32bit READ LE regdata = 0x%x\n", regdata));
+
+#ifndef HSMODE
+               wrregdata |= (CLOCK_PHASE | CLOCK_POLARITY);
+               wrregdata &= ~HIGH_SPEED_MODE;
+               bcmspi_card_regwrite(sd, 0, SPID_CONFIG, 4, wrregdata);
+#endif /* HSMODE */
+
+               for (i = 0; i < INIT_ADAPT_LOOP; i++) {
+                       if ((regdata == 0xfdda7d5b) || (regdata == 0xfdda7d5a)) {
+                               sd_trace(("0xfeedbead was leftshifted by 1-bit.\n"));
+                               if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4,
+                                    &regdata)) != SUCCESS)
+                                       return FALSE;
+                       }
+                       OSL_DELAY(1000);
+               }
+
+
+               /* Change to host controller intr-polarity of active-low */
+               wrregdata &= ~INTR_POLARITY;
+               sd_trace(("(we are still in 16bit mode) 32bit Write LE reg-ctrl-data = 0x%x\n",
+                       wrregdata));
+               /* Change to 32bit mode */
+               wrregdata |= WORD_LENGTH_32;
+               bcmspi_card_regwrite(sd, 0, SPID_CONFIG, 4, wrregdata);
+
+               /* Change command/data packaging in 32bit LE mode */
+               sd->wordlen = 4;
+
+               if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, &regdata)) != SUCCESS)
+                       return FALSE;
+
+               if (regdata == TEST_RO_DATA_32BIT_LE) {
+                       sd_trace(("Read spid passed. Value read = 0x%x\n", regdata));
+                       sd_trace(("Spid had power-on cycle OR spi was soft-resetted \n"));
+               } else {
+                       sd_err(("Stale spid reg values read as it was kept powered. Value read ="
+                         "0x%x\n", regdata));
+                       return FALSE;
+               }
+       }
+
+
+       return TRUE;
+}
+
+static bool
+bcmspi_test_card(sdioh_info_t *sd)
+{
+       uint32 regdata;
+       int status;
+
+       if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_READ, 4, &regdata)) != SUCCESS)
+               return FALSE;
+
+       if (regdata == (TEST_RO_DATA_32BIT_LE))
+               sd_trace(("32bit LE regdata = 0x%x\n", regdata));
+       else {
+               sd_trace(("Incorrect 32bit LE regdata = 0x%x\n", regdata));
+               return FALSE;
+       }
+
+
+#define RW_PATTERN1    0xA0A1A2A3
+#define RW_PATTERN2    0x4B5B6B7B
+
+       regdata = RW_PATTERN1;
+       if ((status = bcmspi_card_regwrite(sd, 0, SPID_TEST_RW, 4, regdata)) != SUCCESS)
+               return FALSE;
+       regdata = 0;
+       if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_RW, 4, &regdata)) != SUCCESS)
+               return FALSE;
+       if (regdata != RW_PATTERN1) {
+               sd_err(("Write-Read spid failed. Value wrote = 0x%x, Value read = 0x%x\n",
+                       RW_PATTERN1, regdata));
+               return FALSE;
+       } else
+               sd_trace(("R/W spid passed. Value read = 0x%x\n", regdata));
+
+       regdata = RW_PATTERN2;
+       if ((status = bcmspi_card_regwrite(sd, 0, SPID_TEST_RW, 4, regdata)) != SUCCESS)
+               return FALSE;
+       regdata = 0;
+       if ((status = bcmspi_card_regread(sd, 0, SPID_TEST_RW, 4, &regdata)) != SUCCESS)
+               return FALSE;
+       if (regdata != RW_PATTERN2) {
+               sd_err(("Write-Read spid failed. Value wrote = 0x%x, Value read = 0x%x\n",
+                       RW_PATTERN2, regdata));
+               return FALSE;
+       } else
+               sd_trace(("R/W spid passed. Value read = 0x%x\n", regdata));
+
+       return TRUE;
+}
+
+static int
+bcmspi_driver_init(sdioh_info_t *sd)
+{
+       sd_trace(("%s\n", __FUNCTION__));
+       if ((bcmspi_host_init(sd)) != SUCCESS) {
+               return ERROR;
+       }
+
+       if (bcmspi_client_init(sd) != SUCCESS) {
+               return ERROR;
+       }
+
+       return SUCCESS;
+}
+
+/* Read device reg */
+static int
+bcmspi_card_regread(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 *data)
+{
+       int status;
+       uint32 cmd_arg, dstatus;
+
+       ASSERT(regsize);
+
+       if (func == 2)
+               sd_trace(("Reg access on F2 will generate error indication in dstatus bits.\n"));
+
+       cmd_arg = 0;
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 0);
+       cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);       /* Incremental access */
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+       cmd_arg = SFIELD(cmd_arg, SPI_LEN, regsize == BLOCK_SIZE_F2 ? 0 : regsize);
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+       sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, 0, func,
+                regaddr, *data));
+
+       if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg, data, regsize))
+           != SUCCESS)
+               return status;
+
+       bcmspi_cmd_getdstatus(sd, &dstatus);
+       if (dstatus)
+               sd_trace(("dstatus =0x%x\n", dstatus));
+
+       return SUCCESS;
+}
+
+static int
+bcmspi_card_regread_fixedaddr(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 *data)
+{
+
+       int status;
+       uint32 cmd_arg;
+       uint32 dstatus;
+
+       ASSERT(regsize);
+
+       if (func == 2)
+               sd_trace(("Reg access on F2 will generate error indication in dstatus bits.\n"));
+
+       cmd_arg = 0;
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 0);
+       cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 0);       /* Fixed access */
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+       cmd_arg = SFIELD(cmd_arg, SPI_LEN, regsize);
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+
+       if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg, data, regsize))
+           != SUCCESS)
+               return status;
+
+       sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, 0, func,
+                regaddr, *data));
+
+       bcmspi_cmd_getdstatus(sd, &dstatus);
+       sd_trace(("dstatus =0x%x\n", dstatus));
+       return SUCCESS;
+}
+
+/* write a device register */
+static int
+bcmspi_card_regwrite(sdioh_info_t *sd, int func, uint32 regaddr, int regsize, uint32 data)
+{
+       int status;
+       uint32 cmd_arg, dstatus;
+
+       ASSERT(regsize);
+
+       cmd_arg = 0;
+
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 1);
+       cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);       /* Incremental access */
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+       cmd_arg = SFIELD(cmd_arg, SPI_LEN, regsize == BLOCK_SIZE_F2 ? 0 : regsize);
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+       sd_trace(("%s: rw=%d, func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, 1, func,
+                regaddr, data));
+
+
+       if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg, &data, regsize))
+           != SUCCESS)
+               return status;
+
+       bcmspi_cmd_getdstatus(sd, &dstatus);
+       if (dstatus)
+               sd_trace(("dstatus =0x%x\n", dstatus));
+
+       return SUCCESS;
+}
+
+/* write a device register - 1 byte */
+static int
+bcmspi_card_bytewrite(sdioh_info_t *sd, int func, uint32 regaddr, uint8 *byte)
+{
+       int status;
+       uint32 cmd_arg;
+       uint32 dstatus;
+       uint32 data = (uint32)(*byte);
+
+       cmd_arg = 0;
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);       /* Incremental access */
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, regaddr);
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, 1);
+       cmd_arg = SFIELD(cmd_arg, SPI_LEN, 1);
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+       sd_trace(("%s: func=%d, regaddr=0x%08x, data=0x%x\n", __FUNCTION__, func,
+                regaddr, data));
+
+       if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma,
+                                     cmd_arg, &data, 1)) != SUCCESS) {
+               return status;
+       }
+
+       bcmspi_cmd_getdstatus(sd, &dstatus);
+       if (dstatus)
+               sd_trace(("dstatus =0x%x\n", dstatus));
+
+       return SUCCESS;
+}
+
+void
+bcmspi_cmd_getdstatus(sdioh_info_t *sd, uint32 *dstatus_buffer)
+{
+       *dstatus_buffer = sd->card_dstatus;
+}
+
+/* 'data' is of type uint32 whereas other buffers are of type uint8 */
+static int
+bcmspi_cmd_issue(sdioh_info_t *sd, bool use_dma, uint32 cmd_arg,
+                uint32 *data, uint32 datalen)
+{
+       uint32  i, j;
+       uint8   resp_delay = 0;
+       int     err = SUCCESS;
+       uint32  hostlen;
+       uint32 spilen = 0;
+       uint32 dstatus_idx = 0;
+       uint16 templen, buslen, len, *ptr = NULL;
+
+       sd_trace(("spi cmd = 0x%x\n", cmd_arg));
+
+       if (DWORDMODE_ON) {
+               spilen = GFIELD(cmd_arg, SPI_LEN);
+               if ((GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_0) ||
+                   (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_1))
+                       dstatus_idx = spilen * 3;
+
+               if ((GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2) &&
+                   (GFIELD(cmd_arg, SPI_RW_FLAG) == 1)) {
+                       spilen = spilen << 2;
+                       dstatus_idx = (spilen % 16) ? (16 - (spilen % 16)) : 0;
+                       /* convert len to mod16 size */
+                       spilen = ROUNDUP(spilen, 16);
+                       cmd_arg = SFIELD(cmd_arg, SPI_LEN, (spilen >> 2));
+               }
+       }
+
+       /* Set up and issue the SPI command.  MSByte goes out on bus first.  Increase datalen
+        * according to the wordlen mode(16/32bit) the device is in.
+        */
+       if (sd->wordlen == 4) { /* 32bit spid */
+               *(uint32 *)spi_outbuf = bcmswap32(cmd_arg);
+               if (datalen & 0x3)
+                       datalen += (4 - (datalen & 0x3));
+       } else if (sd->wordlen == 2) { /* 16bit spid */
+               *(uint16 *)spi_outbuf = bcmswap16(cmd_arg & 0xffff);
+               *(uint16 *)&spi_outbuf[2] = bcmswap16((cmd_arg & 0xffff0000) >> 16);
+               if (datalen & 0x1)
+                       datalen++;
+               if (datalen < 4)
+                       datalen = ROUNDUP(datalen, 4);
+       } else {
+               sd_err(("Host is %d bit spid, could not create SPI command.\n",
+                       8 * sd->wordlen));
+               return ERROR;
+       }
+
+       /* for Write, put the data into the output buffer */
+       if (GFIELD(cmd_arg, SPI_RW_FLAG) == 1) {
+               /* We send len field of hw-header always a mod16 size, both from host and dongle */
+               if (DWORDMODE_ON) {
+                       if (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2) {
+                               ptr = (uint16 *)&data[0];
+                               templen = *ptr;
+                               /* ASSERT(*ptr == ~*(ptr + 1)); */
+                               templen = ROUNDUP(templen, 16);
+                               *ptr = templen;
+                               sd_trace(("actual tx len = %d\n", (uint16)(~*(ptr+1))));
+                       }
+               }
+
+               if (datalen != 0) {
+                       for (i = 0; i < datalen/4; i++) {
+                               if (sd->wordlen == 4) { /* 32bit spid */
+                                       *(uint32 *)&spi_outbuf[i * 4 + CMDLEN] =
+                                               bcmswap32(data[i]);
+                               } else if (sd->wordlen == 2) { /* 16bit spid */
+                                       *(uint16 *)&spi_outbuf[i * 4 + CMDLEN] =
+                                               bcmswap16(data[i] & 0xffff);
+                                       *(uint16 *)&spi_outbuf[i * 4 + CMDLEN + 2] =
+                                               bcmswap16((data[i] & 0xffff0000) >> 16);
+                               }
+                       }
+               }
+       }
+
+       /* Append resp-delay number of bytes and clock them out for F0/1/2 reads. */
+       if (GFIELD(cmd_arg, SPI_RW_FLAG) == 0) {
+               int func = GFIELD(cmd_arg, SPI_FUNCTION);
+               switch (func) {
+                       case 0:
+                               resp_delay = sd->resp_delay_all ? F0_RESPONSE_DELAY : 0;
+                               break;
+                       case 1:
+                               resp_delay = F1_RESPONSE_DELAY;
+                               break;
+                       case 2:
+                               resp_delay = sd->resp_delay_all ? F2_RESPONSE_DELAY : 0;
+                               break;
+                       default:
+                               ASSERT(0);
+                               break;
+               }
+               /* Program response delay */
+               bcmspi_prog_resp_delay(sd, func, resp_delay);
+       }
+
+       /* +4 for cmd and +4 for dstatus */
+       hostlen = datalen + 8 + resp_delay;
+       hostlen += dstatus_idx;
+       hostlen += (4 - (hostlen & 0x3));
+       spi_sendrecv(sd, spi_outbuf, spi_inbuf, hostlen);
+
+       /* for Read, get the data into the input buffer */
+       if (datalen != 0) {
+               if (GFIELD(cmd_arg, SPI_RW_FLAG) == 0) { /* if read cmd */
+                       for (j = 0; j < datalen/4; j++) {
+                               if (sd->wordlen == 4) { /* 32bit spid */
+                                       data[j] = bcmswap32(*(uint32 *)&spi_inbuf[j * 4 +
+                                                   CMDLEN + resp_delay]);
+                               } else if (sd->wordlen == 2) { /* 16bit spid */
+                                       data[j] = (bcmswap16(*(uint16 *)&spi_inbuf[j * 4 +
+                                                   CMDLEN + resp_delay])) |
+                                                ((bcmswap16(*(uint16 *)&spi_inbuf[j * 4 +
+                                                   CMDLEN + resp_delay + 2])) << 16);
+                               }
+                       }
+
+                       if ((DWORDMODE_ON) && (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2)) {
+                               ptr = (uint16 *)&data[0];
+                               templen = *ptr;
+                               buslen = len = ~(*(ptr + 1));
+                               buslen = ROUNDUP(buslen, 16);
+                               /* populate actual len in hw-header */
+                               if (templen == buslen)
+                                       *ptr = len;
+                       }
+               }
+       }
+
+       /* Restore back the len field of the hw header */
+       if (DWORDMODE_ON) {
+               if ((GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2) &&
+                   (GFIELD(cmd_arg, SPI_RW_FLAG) == 1)) {
+                       ptr = (uint16 *)&data[0];
+                       *ptr = (uint16)(~*(ptr+1));
+               }
+       }
+
+       dstatus_idx += (datalen + CMDLEN + resp_delay);
+       /* Last 4bytes are dstatus.  Device is configured to return status bits. */
+       if (sd->wordlen == 4) { /* 32bit spid */
+               sd->card_dstatus = bcmswap32(*(uint32 *)&spi_inbuf[dstatus_idx]);
+       } else if (sd->wordlen == 2) { /* 16bit spid */
+               sd->card_dstatus = (bcmswap16(*(uint16 *)&spi_inbuf[dstatus_idx]) |
+                                  (bcmswap16(*(uint16 *)&spi_inbuf[dstatus_idx + 2]) << 16));
+       } else {
+               sd_err(("Host is %d bit machine, could not read SPI dstatus.\n",
+                       8 * sd->wordlen));
+               return ERROR;
+       }
+       if (sd->card_dstatus == 0xffffffff) {
+               sd_err(("looks like not a GSPI device or device is not powered.\n"));
+       }
+
+       err = bcmspi_update_stats(sd, cmd_arg);
+
+       return err;
+
+}
+
+static int
+bcmspi_card_buf(sdioh_info_t *sd, int rw, int func, bool fifo,
+                uint32 addr, int nbytes, uint32 *data)
+{
+       int status;
+       uint32 cmd_arg;
+       bool write = rw == SDIOH_READ ? 0 : 1;
+       uint retries = 0;
+
+       bool enable;
+       uint32  spilen;
+
+       cmd_arg = 0;
+
+       ASSERT(nbytes);
+       ASSERT(nbytes <= sd->client_block_size[func]);
+
+       if (write) sd->t_cnt++; else sd->r_cnt++;
+
+       if (func == 2) {
+               /* Frame len check limited by gSPI. */
+               if ((nbytes > 2000) && write) {
+                       sd_trace((">2KB write: F2 wr of %d bytes\n", nbytes));
+               }
+               /* ASSERT(nbytes <= 2048); Fix bigger len gspi issue and uncomment. */
+               /* If F2 fifo on device is not ready to receive data, don't do F2 transfer */
+               if (write) {
+                       uint32 dstatus;
+                       /* check F2 ready with cached one */
+                       bcmspi_cmd_getdstatus(sd, &dstatus);
+                       if ((dstatus & STATUS_F2_RX_READY) == 0) {
+                               retries = WAIT_F2RXFIFORDY;
+                               enable = 0;
+                               while (retries-- && !enable) {
+                                       OSL_DELAY(WAIT_F2RXFIFORDY_DELAY * 1000);
+                                       bcmspi_card_regread(sd, SPI_FUNC_0, SPID_STATUS_REG, 4,
+                                                          &dstatus);
+                                       if (dstatus & STATUS_F2_RX_READY)
+                                               enable = TRUE;
+                               }
+                               if (!enable) {
+                                       struct spierrstats_t *spierrstats = &sd->spierrstats;
+                                       spierrstats->f2rxnotready++;
+                                       sd_err(("F2 FIFO is not ready to receive data.\n"));
+                                       return ERROR;
+                               }
+                               sd_trace(("No of retries on F2 ready %d\n",
+                                       (WAIT_F2RXFIFORDY - retries)));
+                       }
+               }
+       }
+
+       /* F2 transfers happen on 0 addr */
+       addr = (func == 2) ? 0 : addr;
+
+       /* In pio mode buffer is read using fixed address fifo in func 1 */
+       if ((func == 1) && (fifo))
+               cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 0);
+       else
+               cmd_arg = SFIELD(cmd_arg, SPI_ACCESS, 1);
+
+       cmd_arg = SFIELD(cmd_arg, SPI_FUNCTION, func);
+       cmd_arg = SFIELD(cmd_arg, SPI_REG_ADDR, addr);
+       cmd_arg = SFIELD(cmd_arg, SPI_RW_FLAG, write);
+       spilen = sd->data_xfer_count = MIN(sd->client_block_size[func], nbytes);
+       if ((sd->dwordmode == TRUE) && (GFIELD(cmd_arg, SPI_FUNCTION) == SPI_FUNC_2)) {
+               /* convert len to mod4 size */
+               spilen = spilen + ((spilen & 0x3) ? (4 - (spilen & 0x3)): 0);
+               cmd_arg = SFIELD(cmd_arg, SPI_LEN, (spilen >> 2));
+       } else
+               cmd_arg = SFIELD(cmd_arg, SPI_LEN, spilen);
+
+       if ((func == 2) && (fifo == 1)) {
+               sd_data(("%s: %s func %d, %s, addr 0x%x, len %d bytes, r_cnt %d t_cnt %d\n",
+                         __FUNCTION__, write ? "Wr" : "Rd", func, "INCR",
+                         addr, nbytes, sd->r_cnt, sd->t_cnt));
+       }
+
+       sd_trace(("%s cmd_arg = 0x%x\n", __FUNCTION__, cmd_arg));
+       sd_data(("%s: %s func %d, %s, addr 0x%x, len %d bytes, r_cnt %d t_cnt %d\n",
+                __FUNCTION__, write ? "Wd" : "Rd", func, "INCR",
+                addr, nbytes, sd->r_cnt, sd->t_cnt));
+
+
+       if ((status = bcmspi_cmd_issue(sd, sd->sd_use_dma, cmd_arg,
+            data, nbytes)) != SUCCESS) {
+               sd_err(("%s: cmd_issue failed for %s\n", __FUNCTION__,
+                       (write ? "write" : "read")));
+               return status;
+       }
+
+       /* gSPI expects that hw-header-len is equal to spi-command-len */
+       if ((func == 2) && (rw == SDIOH_WRITE) && (sd->dwordmode == FALSE)) {
+               ASSERT((uint16)sd->data_xfer_count == (uint16)(*data & 0xffff));
+               ASSERT((uint16)sd->data_xfer_count == (uint16)(~((*data & 0xffff0000) >> 16)));
+       }
+
+       if ((nbytes > 2000) && !write) {
+               sd_trace((">2KB read: F2 rd of %d bytes\n", nbytes));
+       }
+
+       return SUCCESS;
+}
+
+/* Reset and re-initialize the device */
+int
+sdioh_sdio_reset(sdioh_info_t *si)
+{
+       si->card_init_done = FALSE;
+       return bcmspi_client_init(si);
+}
index 09da65c51c310742fcb0433fc1a5b4c2b665872e..dca30396a4e6e3ad5392d4aa2ce003248a9a93e8 100644 (file)
@@ -24,7 +24,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd.h,v 1.32.4.7.2.4.14.44 2010/06/03 21:27:48 Exp $
+ * $Id: dhd.h,v 1.32.4.7.2.4.14.49.4.7 2010/11/12 22:48:36 Exp $
  */
 
 /****************
@@ -35,9 +35,6 @@
 #define _dhd_h_
 
 #if defined(LINUX)
-#if defined(CHROMIUMOS_COMPAT_WIRELESS)
-#include <linux/sched.h>
-#endif
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/random.h>
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
+#include <linux/sched.h>
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-#include <linux/wakelock.h>
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
+
 /* The kernel threading is sdio-specific */
 #else /* LINUX */
 #define ENOMEM         1
 
 #include <wlioctl.h>
 
+#ifdef DHD_DEBUG
+#ifndef DHD_DEBUG_TRAP
+#define DHD_DEBUG_TRAP
+#endif
+#endif
 
 /* Forward decls */
 struct dhd_bus;
@@ -86,9 +87,11 @@ enum dhd_bus_wake_state {
        WAKE_LOCK_TMOUT,
        WAKE_LOCK_WATCHDOG,
        WAKE_LOCK_LINK_DOWN_TMOUT,
+       WAKE_LOCK_PNO_FIND_TMOUT,
        WAKE_LOCK_SOFTAP_SET,
        WAKE_LOCK_SOFTAP_STOP,
        WAKE_LOCK_SOFTAP_START,
+       WAKE_LOCK_SOFTAP_THREAD,
        WAKE_LOCK_MAX
 };
 enum dhd_prealloc_index {
@@ -141,7 +144,7 @@ typedef struct dhd_pub {
 
        ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
        ulong tx_realloc;       /* Number of tx packets we had to realloc for headroom */
-       ulong fc_packets;       /* Number of flow control pkts recvd */
+       ulong fc_packets;       /* Number of flow control pkts recvd */
 
        /* Last error return */
        int bcmerror;
@@ -150,6 +153,14 @@ typedef struct dhd_pub {
        /* Last error from dongle */
        int dongle_error;
 
+       /* Suspend disable flag and "in suspend" flag */
+       int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
+       int in_suspend;                 /* flag set to 1 when early suspend called */
+#ifdef PNO_SUPPORT
+       int pno_enable;                 /* pno status : "1" is pno enable */
+#endif /* PNO_SUPPORT */
+       int dtim_skip;         /* dtim skip , default 0 means wake each dtim */
+
        /* Pkt filter defination */
        char * pktfilter[100];
        int pktfilter_count;
@@ -157,26 +168,19 @@ typedef struct dhd_pub {
        uint8 country_code[WLC_CNTRY_BUF_SZ];
        char eventmask[WL_EVENTING_MASK_LEN];
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-       struct wake_lock        wakelock[WAKE_LOCK_MAX];
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       struct mutex    wl_start_stop_lock; /* lock/unlock for Android start/stop */
-       struct mutex    wl_softap_lock;          /* lock/unlock for any SoftAP/STA settings */
-#endif 
 } dhd_pub_t;
 
-
-       #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
 
        #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
-       #define _DHD_PM_RESUME_WAIT(a, b) do {\
+       #define _DHD_PM_RESUME_WAIT(a, b) do { \
                        int retry = 0; \
+                       smp_mb(); \
                        while (dhd_mmc_suspend && retry++ != b) { \
-                               wait_event_timeout(a, FALSE, HZ/100); \
+                               wait_event_interruptible_timeout(a, FALSE, HZ/100); \
                        } \
                }       while (0)
-       #define DHD_PM_RESUME_WAIT(a)                   _DHD_PM_RESUME_WAIT(a, 30)
+       #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)
@@ -185,12 +189,12 @@ typedef struct dhd_pub {
        #define SPINWAIT_SLEEP(a, exp, us) do { \
                uint countdown = (us) + 9999; \
                while ((exp) && (countdown >= 10000)) { \
-                       wait_event_timeout(a, FALSE, HZ/100); \
+                       wait_event_interruptible_timeout(a, FALSE, HZ/100); \
                        countdown -= 10000; \
                } \
        } while (0)
 
-       #else
+#else
 
        #define DHD_PM_RESUME_WAIT_INIT(a)
        #define DHD_PM_RESUME_WAIT(a)
@@ -207,111 +211,20 @@ typedef struct dhd_pub {
                } \
        } while (0)
 
-       #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
+
 #define DHD_IF_VIF     0x01    /* Virtual IF (Hidden from user) */
 
-inline static void MUTEX_LOCK_INIT(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_init(&dhdp->wl_start_stop_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_lock(&dhdp->wl_start_stop_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_UNLOCK(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_unlock(&dhdp->wl_start_stop_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_init(&dhdp->wl_softap_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_lock(&dhdp->wl_softap_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_unlock(&dhdp->wl_softap_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-extern struct mutex  g_wl_ss_scan_lock;                 /* lock/unlock for Scan/Cache settings */
-#endif 
-
-inline static void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_init(&g_wl_ss_scan_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_LOCK_WL_SCAN_SET(void)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_lock(&g_wl_ss_scan_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void MUTEX_UNLOCK_WL_SCAN_SET(void)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       mutex_unlock(&g_wl_ss_scan_lock);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-}
-
-inline static void WAKE_LOCK_INIT(dhd_pub_t * dhdp, int index, char * y)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-       wake_lock_init(&dhdp->wakelock[index], WAKE_LOCK_SUSPEND, y);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_LOCK(dhd_pub_t * dhdp, int index)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-       wake_lock(&dhdp->wakelock[index]);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_UNLOCK(dhd_pub_t * dhdp, int index)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-       wake_unlock(&dhdp->wakelock[index]);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_LOCK_TIMEOUT(dhd_pub_t * dhdp, int index, long time)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-       wake_lock_timeout(&dhdp->wakelock[index], time);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
-
-inline static void WAKE_LOCK_DESTROY(dhd_pub_t * dhdp, int index)
-{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
-       wake_lock_destroy(&dhdp->wakelock[index]);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
-}
+/* Wakelock Functions */
+extern int dhd_os_wake_lock(dhd_pub_t *pub);
+extern int dhd_os_wake_unlock(dhd_pub_t *pub);
+extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
+extern int dhd_os_wake_lock_timeout_enable(dhd_pub_t *pub);
 
+extern void dhd_os_start_lock(dhd_pub_t *pub);
+extern void dhd_os_start_unlock(dhd_pub_t *pub);
+extern unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
+extern void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
 
 typedef struct dhd_if_event {
        uint8 ifidx;
@@ -378,7 +291,7 @@ extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
 extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
 extern void dhd_customer_gpio_wlan_ctrl(int onoff);
-extern int     dhd_custom_get_mac_address(unsigned char *buf);
+extern int dhd_custom_get_mac_address(unsigned char *buf);
 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
 extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
 extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
@@ -440,8 +353,11 @@ typedef enum cust_gpio_modes {
        WLAN_POWER_ON,
        WLAN_POWER_OFF
 } cust_gpio_modes_t;
+
 extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
 extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
+extern int net_os_send_hang_message(struct net_device *dev);
+
 /*
  * Insmod parameters for debug/test
  */
@@ -491,6 +407,10 @@ extern uint dhd_sdiod_drive_strength;
 /* Override to force tx queueing all the time */
 extern uint dhd_force_tx_queueing;
 
+/* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
+#define KEEP_ALIVE_PERIOD 55000
+#define NULL_PKT_STR   "null_pkt"
+
 #ifdef SDTEST
 /* Echo packet generator (SDIO), pkts/s */
 extern uint dhd_pktgen;
@@ -511,21 +431,8 @@ extern char nv_path[MOD_PARAM_PATHLEN];
 #define DHD_DEL_IF     -0xe
 #define DHD_BAD_IF     -0xf
 
-#ifdef APSTA_PINGTEST
-#define MAX_GUEST 8
-#endif
 
 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
 extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
 
-//hojie: for wifi power control
-#define ANDROID_POWER_SAVE 1
-
-#ifndef CONFIG_BCM4319_FW_PATH
-#define CONFIG_BCM4319_FW_PATH       "/etc/firmware/sdio-g-cdc-full11n-reclaim-roml-wme.bin"
-#endif
-#ifndef CONFIG_BCM4319_NVRAM_PATH
-#define CONFIG_BCM4319_NVRAM_PATH    "/etc/firmware/nvram_4319_201008.txt"
-#endif
-
 #endif /* _dhd_h_ */
index 9e29fb955444611dad6cd1bc0840963ee68d0359..97af41b313d0f3a0e32aadf257fe1ec24dd0400e 100644 (file)
@@ -24,7 +24,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_bus.h,v 1.4.6.3.2.3.6.6 2010/05/17 18:18:13 Exp $
+ * $Id: dhd_bus.h,v 1.4.6.3.2.3.6.7 2010/08/13 01:35:24 Exp $
  */
 
 #ifndef _dhd_bus_h_
@@ -63,7 +63,7 @@ extern bool dhd_bus_watchdog(dhd_pub_t *dhd);
 #ifdef DHD_DEBUG
 /* Device console input function */
 extern int dhd_bus_console_in(dhd_pub_t *dhd, uchar *msg, uint msglen);
-#endif
+#endif /* DHD_DEBUG */
 
 /* Deferred processing for the bus, return TRUE requests reschedule */
 extern bool dhd_bus_dpc(struct dhd_bus *bus);
index 3abfbf8203685bb861973c660b974f260bd3eae1..a68ad61c58b4f8d6596bb8e27f604d902b0e2c46 100644 (file)
 #include <dhd_proto.h>
 #include <dhd_bus.h>
 #include <dhd_dbg.h>
-#ifdef CUSTOMER_HW2
-int wifi_get_mac_addr(unsigned char *buf);
-#endif
 
-extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
+uint8 wlan_mac_addr[ETHER_ADDR_LEN];
 
+extern int dhd_preinit_ioctls(dhd_pub_t *dhd);
 
 /* Packet alignment for most efficient SDIO (can change based on platform) */
 #ifndef DHD_SDALIGN
@@ -78,11 +76,13 @@ dhdcdc_msg(dhd_pub_t *dhd)
 {
        dhd_prot_t *prot = dhd->prot;
        int len = ltoh32(prot->msg.len) + sizeof(cdc_ioctl_t);
+       int ret;
 
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
-       /* 
-        * NOTE : cdc->msg.len holds the desired length of the buffer to be
+       dhd_os_wake_lock(dhd);
+
+       /* NOTE : cdc->msg.len holds the desired length of the buffer to be
         *        returned. Only up to CDC_MAX_MSG_SIZE of this buffer area
         *        is actually sent to the dongle
         */
@@ -90,7 +90,9 @@ dhdcdc_msg(dhd_pub_t *dhd)
                len = CDC_MAX_MSG_SIZE;
 
        /* Send request */
-       return dhd_bus_txctl(dhd->bus, (uchar*)&prot->msg, len);
+       ret = dhd_bus_txctl(dhd->bus, (uchar*)&prot->msg, len);
+       dhd_os_wake_unlock(dhd);
+       return ret;
 }
 
 static int
@@ -201,7 +203,7 @@ dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len)
        cdc_ioctl_t *msg = &prot->msg;
        int ret = 0;
        uint32 flags, id;
-       
+
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
        DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len));
 
@@ -250,7 +252,7 @@ dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len)
 {
        dhd_prot_t *prot = dhd->prot;
        int ret = -1;
-       
+
        if (dhd->busstate == DHD_BUS_DOWN) {
                DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
                return ret;
@@ -323,23 +325,12 @@ dhd_prot_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf)
        bcm_bprintf(strbuf, "Protocol CDC: reqid %d\n", dhdp->prot->reqid);
 }
 
-#ifdef APSTA_PINGTEST
-extern struct ether_addr guest_eas[MAX_GUEST];
-#endif
 
 void
 dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, void *pktbuf)
 {
 #ifdef BDC
        struct bdc_header *h;
-#ifdef APSTA_PINGTEST
-       struct  ether_header *eh;
-       int i;
-#ifdef DHD_DEBUG
-       char eabuf1[ETHER_ADDR_STR_LEN];
-       char eabuf2[ETHER_ADDR_STR_LEN];
-#endif /* DHD_DEBUG */
-#endif /* APSTA_PINGTEST */
 #endif /* BDC */
 
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
@@ -347,9 +338,6 @@ dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, void *pktbuf)
 #ifdef BDC
        /* Push BDC header used to convey priority for buses that don't */
 
-#ifdef APSTA_PINGTEST
-       eh = (struct ether_header *)PKTDATA(dhd->osh, pktbuf);
-#endif
 
        PKTPUSH(dhd->osh, pktbuf, BDC_HEADER_LEN);
 
@@ -362,19 +350,6 @@ dhd_prot_hdrpush(dhd_pub_t *dhd, int ifidx, void *pktbuf)
 
        h->priority = (PKTPRIO(pktbuf) & BDC_PRIORITY_MASK);
        h->flags2 = 0;
-#ifdef APSTA_PINGTEST
-       for (i = 0; i < MAX_GUEST; ++i) {
-               if (!ETHER_ISNULLADDR(eh->ether_dhost) &&
-                   bcmp(eh->ether_dhost, guest_eas[i].octet, ETHER_ADDR_LEN) == 0) {
-                       DHD_TRACE(("send on if 1; sa %s, da %s\n",
-                              bcm_ether_ntoa((struct ether_addr *)(eh->ether_shost), eabuf1),
-                              bcm_ether_ntoa((struct ether_addr *)(eh->ether_dhost), eabuf2)));
-                       /* assume all guest STAs are on interface 1 */
-                       h->flags2 = 1;
-                       break;
-               }
-       }
-#endif /* APSTA_PINGTEST */
        h->rssi = 0;
 #endif /* BDC */
        BDC_SET_IF_IDX(h, ifidx);
@@ -529,6 +504,7 @@ dhd_prot_init(dhd_pub_t *dhd)
                return ret;
        }
        memcpy(dhd->mac.octet, buf, ETHER_ADDR_LEN);
+        memcpy(wlan_mac_addr, buf, ETHER_ADDR_LEN);
 
        dhd_os_proto_unblock(dhd);
 
index 3800c3d7d2de0eeec8ad17c933167bb6fc020c4d..946ff3f8166bf3ab6f615e892376cf2ab208ff3c 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_common.c,v 1.5.6.8.2.6.6.65 2010/07/07 00:05:07 Exp $
+ * $Id: dhd_common.c,v 1.5.6.8.2.6.6.69.4.20 2010/12/20 23:37:28 Exp $
  */
 #include <typedefs.h>
 #include <osl.h>
 #include <dhd_dbg.h>
 #include <msgtrace.h>
 
-
 #include <wlioctl.h>
 
-int dhd_msg_level;
+#define CONFIG_BCM4319_FW_PATH   "/system/etc/firmware/fw_bcm4319.bin"
+#define CONFIG_BCM4319_NVRAM_PATH  "/system/etc/firmware/nvram.txt"
 
+#ifdef SET_RANDOM_MAC_SOFTAP
+#include <linux/random.h>
+#include <linux/jiffies.h>
+#endif
+
+#ifdef GET_CUSTOM_MAC_ENABLE
+int wifi_get_mac_addr(unsigned char *buf);
+#endif /* GET_CUSTOM_MAC_ENABLE */
+
+int dhd_msg_level;
 
-#if defined(CSCAN)
 #include <wl_iw.h>
-#endif 
 
 char fw_path[MOD_PARAM_PATHLEN];
 char nv_path[MOD_PARAM_PATHLEN];
@@ -66,6 +74,13 @@ extern int dhd_wl_ioctl(dhd_pub_t *dhd, uint cmd, char *buf, uint buflen);
 void dhd_iscan_lock(void);
 void dhd_iscan_unlock(void);
 
+#if defined(SOFTAP)
+extern bool ap_fw_loaded;
+#endif
+#if defined(KEEP_ALIVE)
+int dhd_keep_alive_onoff(dhd_pub_t *dhd, int ka_on);
+#endif /* KEEP_ALIVE */
+
 /* Packet alignment for most efficient SDIO (can change based on platform) */
 #ifndef DHD_SDALIGN
 #define DHD_SDALIGN    32
@@ -229,7 +244,6 @@ dhd_doiovar(dhd_pub_t *dhd_pub, const bcm_iovar_t *vi, uint32 actionid, const ch
                dhd_msg_level = int_val;
                break;
 
-
        case IOV_GVAL(IOV_BCMERRORSTR):
                strncpy((char *)arg, bcmerrorstr(dhd_pub->bcmerror), BCME_STRLEN);
                ((char *)arg)[BCME_STRLEN - 1] = 0x00;
@@ -508,9 +522,6 @@ dhd_ioctl(dhd_pub_t *dhd_pub, dhd_ioctl_t *ioc, void *buf, uint buflen)
        return bcmerror;
 }
 
-#ifdef APSTA_PINGTEST
-struct ether_addr guest_eas[MAX_GUEST];
-#endif
 
 #ifdef SHOW_EVENTS
 static void
@@ -619,16 +630,6 @@ wl_show_host_event(wl_event_msg_t *event, void *event_data)
 
        case WLC_E_ASSOC_IND:
        case WLC_E_REASSOC_IND:
-#ifdef APSTA_PINGTEST
-               {
-                       int i;
-                       for (i = 0; i < MAX_GUEST; ++i)
-                               if (ETHER_ISNULLADDR(&guest_eas[i]))
-                                       break;
-                       if (i < MAX_GUEST)
-                               bcopy(event->addr.octet, guest_eas[i].octet, ETHER_ADDR_LEN);
-               }
-#endif /* APSTA_PINGTEST */
                DHD_EVENT(("MACEVENT: %s, MAC %s\n", event_name, eabuf));
                break;
 
@@ -649,18 +650,6 @@ wl_show_host_event(wl_event_msg_t *event, void *event_data)
 
        case WLC_E_DEAUTH_IND:
        case WLC_E_DISASSOC_IND:
-#ifdef APSTA_PINGTEST
-               {
-                       int i;
-                       for (i = 0; i < MAX_GUEST; ++i) {
-                               if (bcmp(guest_eas[i].octet, event->addr.octet,
-                                        ETHER_ADDR_LEN) == 0) {
-                                       bzero(guest_eas[i].octet, ETHER_ADDR_LEN);
-                                       break;
-                               }
-                       }
-               }
-#endif /* APSTA_PINGTEST */
                DHD_EVENT(("MACEVENT: %s, MAC %s, reason %d\n", event_name, eabuf, (int)reason));
                break;
 
@@ -966,6 +955,7 @@ void print_buf(void *pbuf, int len, int bytes_per_line)
 
 #define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
 
+#ifdef PKT_FILTER_SUPPORT
 /* Convert user's input in hex pattern to byte-size mask */
 static int
 wl_pattern_atoh(char *src, char *dst)
@@ -1195,7 +1185,9 @@ fail:
        if (buf)
                MFREE(dhd->osh, buf, BUF_SIZE);
 }
+#endif
 
+#ifdef ARP_OFFLOAD_SUPPORT
 void
 dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode)
 {
@@ -1229,6 +1221,7 @@ dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable)
                DHD_TRACE(("%s: successfully enabed ARP offload to %d\n",
                __FUNCTION__, arp_enable));
 }
+#endif
 
 int
 dhd_preinit_ioctls(dhd_pub_t *dhd)
@@ -1239,20 +1232,26 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
        uint power_mode = PM_FAST;
        uint32 dongle_align = DHD_SDALIGN;
        uint32 glom = 0;
-       uint bcn_timeout = 3;
+       uint bcn_timeout = 4;
        int scan_assoc_time = 40;
-       int scan_unassoc_time = 80;
-#ifdef GET_CUSTOM_MAC_ENABLE
+       int scan_unassoc_time = 40;
+       uint32 listen_interval = LISTEN_INTERVAL; /* Default Listen Interval in Beacons */
+#if defined(SOFTAP)
+       uint dtim = 1;
+#endif
        int ret = 0;
+#ifdef GET_CUSTOM_MAC_ENABLE
        struct ether_addr ea_addr;
 #endif /* GET_CUSTOM_MAC_ENABLE */
 
        dhd_os_proto_block(dhd);
 
 #ifdef GET_CUSTOM_MAC_ENABLE
-       /* Read MAC address from external customer place
-       ** NOTE that default mac address has to be present in otp or nvram file to bring up
-       ** firmware but unique per board mac address maybe provided by customer code
+       /*
+       ** Read MAC address from external customer place
+       ** NOTE that default mac address has to be present in otp or nvram file
+       ** to bring up firmware but unique per board mac address maybe provided
+       ** by customer code
        */
        ret = dhd_custom_get_mac_address(ea_addr.octet);
        if (!ret) {
@@ -1260,23 +1259,42 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
                ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
                if (ret < 0) {
                        DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
-               }
-               else
+               } else
                        memcpy(dhd->mac.octet, (void *)&ea_addr, ETHER_ADDR_LEN);
        }
-#endif  /* GET_CUSTOM_MAC_ENABLE */
+#endif /* GET_CUSTOM_MAC_ENABLE */
 
-       /*
-        * Initially, country code maybe US, in this situation,
-        * Just 11 channels are supported, but 13 channels should be supported
-        * in China, so we change contry code to EU (Eurapor). -- Yongle Lai
-        */
-       strcpy(dhd->country_code, "EU");
-       dhd->country_code[2] = '\0';
-       
-       /*
-        * Set Country code.
-        */
+#ifdef SET_RANDOM_MAC_SOFTAP
+       if (strstr(fw_path, "apsta") != NULL) {
+               uint rand_mac;
+
+               srandom32((uint)jiffies);
+               rand_mac = random32();
+               iovbuf[0] = 0x02;              /* locally administered bit */
+               iovbuf[1] = 0x1A;
+               iovbuf[2] = 0x11;
+               iovbuf[3] = (unsigned char)(rand_mac & 0x0F) | 0xF0;
+               iovbuf[4] = (unsigned char)(rand_mac >> 8);
+               iovbuf[5] = (unsigned char)(rand_mac >> 16);
+
+               printk("Broadcom Dongle Host Driver mac=%02x:%02x:%02x:%02x:%02x:%02x\n",
+                       iovbuf[0], iovbuf[1], iovbuf[2], iovbuf[3], iovbuf[4], iovbuf[5]);
+
+               bcm_mkiovar("cur_etheraddr", (void *)iovbuf, ETHER_ADDR_LEN, buf, sizeof(buf));
+               ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, sizeof(buf));
+               if (ret < 0) {
+                       DHD_ERROR(("%s: can't set MAC address , error=%d\n", __FUNCTION__, ret));
+               } else
+                       memcpy(dhd->mac.octet, iovbuf, ETHER_ADDR_LEN);
+       }
+#endif /* SET_RANDOM_MAC_SOFTAP */
+
+       /* Set Country code 
+         * "US" ---> 11 channels, this is default setting. 
+         * "EU" ---> 13 channels
+         * "JP" ---> 14 channels
+         */
+        strcpy(dhd->country_code, "EU");
        if (dhd->country_code[0] != 0) {
                if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY,
                        dhd->country_code, sizeof(dhd->country_code)) < 0) {
@@ -1284,10 +1302,11 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
                }
        }
 
-       //dhdcdc_query_ioctl(dhd, 0, WLC_GET_COUNTRY,
-       //                      dhd->country_code, sizeof(dhd->country_code));
-       //printk("============>%s: Current country code: %s\n", __func__, dhd->country_code);
-       
+       /* Set Listen Interval */
+       bcm_mkiovar("assoc_listen", (char *)&listen_interval, 4, iovbuf, sizeof(iovbuf));
+       if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0)
+               DHD_ERROR(("%s assoc_listen failed %d\n", __FUNCTION__, ret));
+
        /* query for 'ver' to get version info from firmware */
        memset(buf, 0, sizeof(buf));
        ptr = buf;
@@ -1316,6 +1335,58 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
        bcm_mkiovar("roam_off", (char *)&dhd_roam, 4, iovbuf, sizeof(iovbuf));
        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 
+#if defined(SOFTAP)
+       if (ap_fw_loaded == TRUE) {
+               dhdcdc_set_ioctl(dhd, 0, WLC_SET_DTIMPRD, (char *)&dtim, sizeof(dtim));
+       }
+#endif
+
+       if (dhd_roam == 0)
+       {
+               /* set internal roaming roaming parameters */
+               int roam_scan_period = 30; /* in sec */
+               int roam_fullscan_period = 120; /* in sec */
+               int roam_trigger = -85;
+               int roam_delta = 15;
+               int band;
+               int band_temp_set = WLC_BAND_2G;
+
+               if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_SCAN_PERIOD, \
+                       (char *)&roam_scan_period, sizeof(roam_scan_period)) < 0)
+                       DHD_ERROR(("%s: roam scan setup failed\n", __FUNCTION__));
+
+               bcm_mkiovar("fullroamperiod", (char *)&roam_fullscan_period, \
+                                        4, iovbuf, sizeof(iovbuf));
+               if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, \
+                       iovbuf, sizeof(iovbuf)) < 0)
+                       DHD_ERROR(("%s: roam fullscan setup failed\n", __FUNCTION__));
+
+               if (dhdcdc_query_ioctl(dhd, 0, WLC_GET_BAND, \
+                               (char *)&band, sizeof(band)) < 0)
+                       DHD_ERROR(("%s: roam delta setting failed\n", __FUNCTION__));
+               else {
+                       if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_ALL))
+                       {
+                               /* temp set band to insert new roams values */
+                               if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_BAND, \
+                                       (char *)&band_temp_set, sizeof(band_temp_set)) < 0)
+                                       DHD_ERROR(("%s: local band seting failed\n", __FUNCTION__));
+                       }
+                       if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_DELTA, \
+                               (char *)&roam_delta, sizeof(roam_delta)) < 0)
+                               DHD_ERROR(("%s: roam delta setting failed\n", __FUNCTION__));
+
+                       if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_ROAM_TRIGGER, \
+                               (char *)&roam_trigger, sizeof(roam_trigger)) < 0)
+                               DHD_ERROR(("%s: roam trigger setting failed\n", __FUNCTION__));
+
+                       /* Restore original band settinngs */
+                       if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_BAND, \
+                               (char *)&band, sizeof(band)) < 0)
+                               DHD_ERROR(("%s: Original band restore failed\n", __FUNCTION__));
+               }
+       }
+
        /* Force STA UP */
        if (dhd_radio_up)
                dhdcdc_set_ioctl(dhd, 0, WLC_UP, (char *)&up, sizeof(up));
@@ -1350,6 +1421,19 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
        }
 #endif /* PKT_FILTER_SUPPORT */
 
+#if defined(KEEP_ALIVE)
+       {
+       /* Set Keep Alive : be sure to use FW with -keepalive */
+       int res;
+
+       if (ap_fw_loaded == FALSE) {
+               if ((res = dhd_keep_alive_onoff(dhd, 1)) < 0)
+                       DHD_ERROR(("%s set keeplive failed %d\n", \
+               __FUNCTION__, res));
+               }
+       }
+#endif
+
        dhd_os_proto_unblock(dhd);
 
        return 0;
@@ -1375,9 +1459,9 @@ dhd_iscan_allocate_buf(dhd_pub_t *dhd, iscan_buf_t **iscanbuf)
        iscanbuf_alloc->next = NULL;
        iscanbuf_head = *iscanbuf;
 
-       DHD_ISCAN(("%s: addr of allocated node = 0x%X, addr of iscanbuf_head \
-               = 0x%X dhd = 0x%X\n", __FUNCTION__, iscanbuf_alloc,
-               iscanbuf_head, dhd));
+       DHD_ISCAN(("%s: addr of allocated node = 0x%X"
+                  "addr of iscanbuf_head = 0x%X dhd = 0x%X\n",
+                  __FUNCTION__, iscanbuf_alloc, iscanbuf_head, dhd));
 
        if (iscanbuf_head == NULL) {
                *iscanbuf = iscanbuf_alloc;
@@ -1404,7 +1488,7 @@ dhd_iscan_free_buf(void *dhdp, iscan_buf_t *iscan_delete)
        dhd_pub_t *dhd = dhd_bus_pub(dhdp);
 
        dhd_iscan_lock();
-       /* If iscan_delete is null then delete the entire 
+       /* If iscan_delete is null then delete the entire
         * chain or else delete specific one provided
         */
        if (!iscan_delete) {
@@ -1538,10 +1622,10 @@ dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
                                        break;
 
                                if (!memcmp(bi->BSSID.octet, addr, ETHER_ADDR_LEN)) {
-                                       DHD_ISCAN(("%s: Del BSS[%2.2d:%2.2d] %X:%X:%X:%X:%X:%X\n", \
-                                       __FUNCTION__, l, i, bi->BSSID.octet[0], \
-                                       bi->BSSID.octet[1], bi->BSSID.octet[2], \
-                                       bi->BSSID.octet[3], bi->BSSID.octet[4], \
+                                       DHD_ISCAN(("%s: Del BSS[%2.2d:%2.2d] %X:%X:%X:%X:%X:%X\n",
+                                       __FUNCTION__, l, i, bi->BSSID.octet[0],
+                                       bi->BSSID.octet[1], bi->BSSID.octet[2],
+                                       bi->BSSID.octet[3], bi->BSSID.octet[4],
                                        bi->BSSID.octet[5]));
 
                                        bi_new = bi;
@@ -1558,8 +1642,8 @@ dhd_iscan_delete_bss(void *dhdp, void *addr, iscan_buf_t *iscan_skip)
 
                                        for (j = i; j < results->count; j++) {
                                                if (bi && bi_new) {
-                                                       DHD_ISCAN(("%s: Moved up BSS[%2.2d:%2.2d] \
-                                                       %X:%X:%X:%X:%X:%X\n",
+                                                       DHD_ISCAN(("%s: Moved up BSS[%2.2d:%2.2d]"
+                                                       "%X:%X:%X:%X:%X:%X\n",
                                                        __FUNCTION__, l, j, bi->BSSID.octet[0],
                                                        bi->BSSID.octet[1], bi->BSSID.octet[2],
                                                        bi->BSSID.octet[3], bi->BSSID.octet[4],
@@ -1735,17 +1819,274 @@ fail:
        return status;
 }
 
-#endif 
+#endif
+
+/* Function to estimate possible DTIM_SKIP value */
+int dhd_get_dtim_skip(dhd_pub_t *dhd)
+{
+       int bcn_li_dtim;
+       char buf[128];
+       int ret;
+       int dtim_assoc = 0;
+
+       if ((dhd->dtim_skip == 0) || (dhd->dtim_skip == 1))
+               bcn_li_dtim = 3;
+       else
+               bcn_li_dtim = dhd->dtim_skip;
+
+       /* Read DTIM value if associated */
+       memset(buf, 0, sizeof(buf));
+       bcm_mkiovar("dtim_assoc", 0, 0, buf, sizeof(buf));
+       if ((ret = dhdcdc_query_ioctl(dhd, 0, WLC_GET_VAR, buf, sizeof(buf))) < 0) {
+               DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));
+               bcn_li_dtim = 1;
+               goto exit;
+       }
+       else
+               dtim_assoc = dtoh32(*(int *)buf);
+
+       DHD_ERROR(("%s bcn_li_dtim=%d DTIM=%d Listen=%d\n", \
+                        __FUNCTION__, bcn_li_dtim, dtim_assoc, LISTEN_INTERVAL));
+
+       /* if not assocated just eixt */
+       if (dtim_assoc == 0) {
+               goto exit;
+       }
+
+       /* check if sta listen interval fits into AP dtim */
+       if (dtim_assoc > LISTEN_INTERVAL) {
+               /* AP DTIM to big for our Listen Interval : no dtim skiping */
+               bcn_li_dtim = 1;
+               DHD_ERROR(("%s DTIM=%d > Listen=%d : too big ...\n", \
+                                __FUNCTION__, dtim_assoc, LISTEN_INTERVAL));
+               goto exit;
+       }
+
+       if ((bcn_li_dtim * dtim_assoc) > LISTEN_INTERVAL) {
+               /* Round up dtim_skip to fit into STAs Listen Interval */
+               bcn_li_dtim = (int)(LISTEN_INTERVAL / dtim_assoc);
+               DHD_TRACE(("%s agjust dtim_skip as %d\n", __FUNCTION__, bcn_li_dtim));
+       }
+
+exit:
+       return bcn_li_dtim;
+}
+
+#ifdef PNO_SUPPORT
+int dhd_pno_clean(dhd_pub_t *dhd)
+{
+       char iovbuf[128];
+       int pfn_enabled = 0;
+       int iov_len = 0;
+       int ret;
+
+       /* Disable pfn */
+       iov_len = bcm_mkiovar("pfn", (char *)&pfn_enabled, 4, iovbuf, sizeof(iovbuf));
+       if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) >= 0) {
+               /* clear pfn */
+               iov_len = bcm_mkiovar("pfnclear", 0, 0, iovbuf, sizeof(iovbuf));
+               if (iov_len) {
+                       if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, iov_len)) < 0) {
+                               DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));
+                       }
+               }
+               else {
+                       ret = -1;
+                       DHD_ERROR(("%s failed code %d\n", __FUNCTION__, iov_len));
+               }
+       }
+       else
+               DHD_ERROR(("%s failed code %d\n", __FUNCTION__, ret));
+
+       return ret;
+}
+
+int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
+{
+       char iovbuf[128];
+       int ret = -1;
+
+       if ((!dhd) && ((pfn_enabled != 0) || (pfn_enabled != 1))) {
+               DHD_ERROR(("%s error exit\n", __FUNCTION__));
+               return ret;
+       }
+
+       /* Enable/disable PNO */
+       if ((ret = bcm_mkiovar("pfn", (char *)&pfn_enabled, 4, iovbuf, sizeof(iovbuf))) > 0) {
+               if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0) {
+                       DHD_ERROR(("%s failed for error=%d\n", __FUNCTION__, ret));
+                       return ret;
+               }
+               else {
+                       dhd->pno_enable = pfn_enabled;
+                       DHD_TRACE(("%s set pno as %d\n", __FUNCTION__, dhd->pno_enable));
+               }
+       }
+       else DHD_ERROR(("%s failed err=%d\n", __FUNCTION__, ret));
+
+       return ret;
+}
+
+/* Function to execute combined scan */
+int
+dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid, ushort scan_fr)
+{
+       int err = -1;
+       char iovbuf[128];
+       int k, i;
+       wl_pfn_param_t pfn_param;
+       wl_pfn_t        pfn_element;
+
+       DHD_TRACE(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, scan_fr));
+
+       if ((!dhd) && (!ssids_local)) {
+               DHD_ERROR(("%s error exit\n", __FUNCTION__));
+               err = -1;
+       }
+
+       /* Check for broadcast ssid */
+       for (k = 0; k < nssid; k++) {
+               if (!ssids_local[k].SSID_len) {
+                       DHD_ERROR(("%d: Broadcast SSID is ilegal for PNO setting\n", k));
+                       return err;
+               }
+       }
+/* #define  PNO_DUMP 1 */
+#ifdef PNO_DUMP
+       {
+               int j;
+               for (j = 0; j < nssid; j++) {
+                       DHD_ERROR(("%d: scan  for  %s size =%d\n", j,
+                               ssids_local[j].SSID, ssids_local[j].SSID_len));
+               }
+       }
+#endif /* PNO_DUMP */
+
+       /* clean up everything */
+       if  ((err = dhd_pno_clean(dhd)) < 0) {
+               DHD_ERROR(("%s failed error=%d\n", __FUNCTION__, err));
+               return err;
+       }
+       memset(&pfn_param, 0, sizeof(pfn_param));
+       memset(&pfn_element, 0, sizeof(pfn_element));
+
+       /* set pfn parameters */
+       pfn_param.version = htod32(PFN_VERSION);
+       pfn_param.flags = htod16((PFN_LIST_ORDER << SORT_CRITERIA_BIT));
+
+       /* set up pno scan fr */
+       if (scan_fr  != 0)
+               pfn_param.scan_freq = htod32(scan_fr);
+
+       if (pfn_param.scan_freq > PNO_SCAN_MAX_FW) {
+               DHD_ERROR(("%s pno freq above %d sec\n", __FUNCTION__, PNO_SCAN_MAX_FW));
+               return err;
+       }
+
+       bcm_mkiovar("pfn_set", (char *)&pfn_param, sizeof(pfn_param), iovbuf, sizeof(iovbuf));
+       dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
+
+       /* set all pfn ssid */
+       for (i = 0; i < nssid; i++) {
+
+               pfn_element.bss_type = htod32(DOT11_BSSTYPE_INFRASTRUCTURE);
+               pfn_element.auth = (DOT11_OPEN_SYSTEM);
+               pfn_element.wpa_auth = htod32(WPA_AUTH_PFN_ANY);
+               pfn_element.wsec = htod32(0);
+               pfn_element.infra = htod32(1);
+
+               memcpy((char *)pfn_element.ssid.SSID, ssids_local[i].SSID, ssids_local[i].SSID_len);
+               pfn_element.ssid.SSID_len = ssids_local[i].SSID_len;
+
+               if ((err =
+               bcm_mkiovar("pfn_add", (char *)&pfn_element,
+                       sizeof(pfn_element), iovbuf, sizeof(iovbuf))) > 0) {
+                       if ((err =
+                       dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0) {
+                               DHD_ERROR(("%s failed for i=%d error=%d\n",
+                                       __FUNCTION__, i, err));
+                               return err;
+                       }
+                       else
+                               DHD_ERROR(("%s set OK with PNO time=%d\n", __FUNCTION__, \
+                                                               pfn_param.scan_freq));
+               }
+               else DHD_ERROR(("%s failed err=%d\n", __FUNCTION__, err));
+       }
+
+       /* Enable PNO */
+       /* dhd_pno_enable(dhd, 1); */
+       return err;
+}
+
+int dhd_pno_get_status(dhd_pub_t *dhd)
+{
+       int ret = -1;
+
+       if (!dhd)
+               return ret;
+       else
+               return (dhd->pno_enable);
+}
+
+#endif /* PNO_SUPPORT */
+
+#if defined(KEEP_ALIVE)
+int dhd_keep_alive_onoff(dhd_pub_t *dhd, int ka_on)
+{
+       char buf[256];
+       char *buf_ptr = buf;
+       wl_keep_alive_pkt_t keep_alive_pkt;
+       char * str;
+       int str_len, buf_len;
+       int res = 0;
+       int keep_alive_period = KEEP_ALIVE_PERIOD; /* in ms */
+
+       DHD_TRACE(("%s: ka:%d\n", __FUNCTION__, ka_on));
+
+       if (ka_on) { /* on suspend */
+               keep_alive_pkt.period_msec = keep_alive_period;
+
+       } else {
+               /* on resume, turn off keep_alive packets  */
+               keep_alive_pkt.period_msec = 0;
+       }
+
+       /* IOC var name  */
+       str = "keep_alive";
+       str_len = strlen(str);
+       strncpy(buf, str, str_len);
+       buf[str_len] = '\0';
+       buf_len = str_len + 1;
+
+       /* set ptr to IOCTL payload after the var name */
+       buf_ptr += buf_len; /* include term Z */
+
+       /* copy Keep-alive attributes from local var keep_alive_pkt */
+       str = NULL_PKT_STR;
+       keep_alive_pkt.len_bytes = strlen(str);
+
+       memcpy(buf_ptr, &keep_alive_pkt, WL_KEEP_ALIVE_FIXED_LEN);
+       buf_ptr += WL_KEEP_ALIVE_FIXED_LEN;
+
+       /* copy packet data */
+       memcpy(buf_ptr, str, keep_alive_pkt.len_bytes);
+       buf_len += (WL_KEEP_ALIVE_FIXED_LEN + keep_alive_pkt.len_bytes);
+
+       res = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, buf, buf_len);
+       return res;
+}
+#endif /* defined(KEEP_ALIVE) */
 
-/* Android ComboSCAN support */
 #if defined(CSCAN)
 
+/* Androd ComboSCAN support */
 /*
  *  data parsing from ComboScan tlv list
 */
 int
-wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token, \
-                       int input_size, int *bytes_left)
+wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token,
+                     int input_size, int *bytes_left)
 {
        char* str = *list_str;
        uint16 short_temp;
@@ -1761,8 +2102,8 @@ wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token,
        while (*bytes_left > 0) {
 
                if (str[0] != token) {
-                       DHD_TRACE(("%s NOT Type=%d get=%d left_parse=%d \n", __FUNCTION__, \
-                                               token, str[0], *bytes_left));
+                       DHD_TRACE(("%s NOT Type=%d get=%d left_parse=%d \n",
+                               __FUNCTION__, token, str[0], *bytes_left));
                        return -1;
                }
 
@@ -1773,11 +2114,11 @@ wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token,
                        memcpy(dst, str, input_size);
                }
                else if (input_size == 2) {
-                       memcpy(dst, (char *)htod16(memcpy(&short_temp, str, input_size)), \
-                                input_size);
+                       memcpy(dst, (char *)htod16(memcpy(&short_temp, str, input_size)),
+                               input_size);
                }
                else if (input_size == 4) {
-                       memcpy(dst, (char *)htod32(memcpy(&int_temp, str, input_size)), \
+                       memcpy(dst, (char *)htod32(memcpy(&int_temp, str, input_size)),
                                input_size);
                }
 
@@ -1793,8 +2134,8 @@ wl_iw_parse_data_tlv(char** list_str, void *dst, int dst_size, const char token,
  *  channel list parsing from cscan tlv list
 */
 int
-wl_iw_parse_channel_list_tlv(char** list_str, uint16* channel_list, \
-                               int channel_num, int *bytes_left)
+wl_iw_parse_channel_list_tlv(char** list_str, uint16* channel_list,
+                             int channel_num, int *bytes_left)
 {
        char* str = *list_str;
        int idx = 0;
@@ -1879,7 +2220,7 @@ wl_iw_parse_ssid_list_tlv(char** list_str, wlc_ssid_t* ssid, int max, int *bytes
 
                        /* Get SSID */
                        if (ssid[idx].SSID_len > *bytes_left) {
-                               DHD_ERROR(("%s out of memory range len=%d but left=%d\n", \
+                               DHD_ERROR(("%s out of memory range len=%d but left=%d\n",
                                __FUNCTION__, ssid[idx].SSID_len, *bytes_left));
                                return -1;
                        }
@@ -1889,8 +2230,8 @@ wl_iw_parse_ssid_list_tlv(char** list_str, wlc_ssid_t* ssid, int max, int *bytes
                        *bytes_left -= ssid[idx].SSID_len;
                        str += ssid[idx].SSID_len;
 
-                       DHD_TRACE(("%s :size=%d left=%d\n", (char*)ssid[idx].SSID, \
-                               ssid[idx].SSID_len, *bytes_left));
+                       DHD_TRACE(("%s :size=%d left=%d\n",
+                               (char*)ssid[idx].SSID, ssid[idx].SSID_len, *bytes_left));
                }
                else {
                        DHD_ERROR(("### SSID size more that %d\n", str[0]));
@@ -1987,4 +2328,4 @@ wl_iw_parse_channel_list(char** list_str, uint16* channel_list, int channel_num)
        return num;
 }
 
-#endif 
+#endif
index d4d7e06b3f65881ed358a1d404b343b19d1b9a94..8c6ec470b8bd2efb54c5811f3fa90a1fffaeba27 100644 (file)
@@ -20,7 +20,7 @@
 * software in any way with any other Broadcom software provided under a license
 * other than the GPL, without Broadcom's express prior written consent.
 *
-* $Id: dhd_custom_gpio.c,v 1.1.4.7 2010/06/03 21:27:48 Exp $
+* $Id: dhd_custom_gpio.c,v 1.1.4.8.4.1 2010/09/02 23:13:16 Exp $
 */
 
 
@@ -34,9 +34,8 @@
 
 #include <wlioctl.h>
 #include <wl_iw.h>
-#include <dhd_dbg.h>
 
-#define WL_ERROR(x) DHD_ERROR(x)
+#define WL_ERROR(x) printf x
 #define WL_TRACE(x)
 
 #ifdef CUSTOMER_HW
@@ -47,6 +46,7 @@ extern  void bcm_wlan_power_on(int);
 int wifi_set_carddetect(int on);
 int wifi_set_power(int on, unsigned long msec);
 int wifi_get_irq_number(unsigned long *irq_flags_ptr);
+int wifi_get_mac_addr(unsigned char *buf);
 #endif
 
 #if defined(OOB_INTR_ONLY)
@@ -78,7 +78,7 @@ int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr)
                dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
        }
 #endif
-       *irq_flags_ptr = IRQF_TRIGGER_FALLING;
+
        if (dhd_oob_gpio_num < 0) {
                WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
                        __FUNCTION__));
@@ -143,9 +143,9 @@ dhd_customer_gpio_wlan_ctrl(int onoff)
                                __FUNCTION__));
 #ifdef CUSTOMER_HW
                        bcm_wlan_power_on(1);
-#endif /* CUSTOMER_HW */
                        /* Lets customer power to get stable */
-                       OSL_DELAY(500);
+                       OSL_DELAY(50);
+#endif /* CUSTOMER_HW */
                break;
        }
 }
@@ -155,11 +155,16 @@ dhd_customer_gpio_wlan_ctrl(int onoff)
 int
 dhd_custom_get_mac_address(unsigned char *buf)
 {
+       int ret = 0;
+
        WL_TRACE(("%s Enter\n", __FUNCTION__));
        if (!buf)
                return -EINVAL;
 
        /* Customer access to MAC address stored outside of DHD driver */
+#ifdef CUSTOMER_HW2
+       ret = wifi_get_mac_addr(buf);
+#endif
 
 #ifdef EXAMPLE_GET_MAC
        /* EXAMPLE code */
@@ -169,6 +174,6 @@ dhd_custom_get_mac_address(unsigned char *buf)
        }
 #endif /* EXAMPLE_GET_MAC */
 
-       return 0;
+       return ret;
 }
 #endif /* GET_CUSTOM_MAC_ENABLE */
index 9f09ce7fcc04ed0f96c4dbacb0ea72131c47d29f..b48c1d70f1441c8dde928f24ac7d9b3823d50d93 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef _dhd_dbg_
 #define _dhd_dbg_
 
-#if 0 || (defined DHD_DEBUG)
+#ifdef DHD_DEBUG
 
 #define DHD_ERROR(args)               do {if ((dhd_msg_level & DHD_ERROR_VAL) && (net_ratelimit())) \
                                                                printf args;} while (0)
@@ -58,7 +58,7 @@
 #define DHD_BTA_ON()           (dhd_msg_level & DHD_BTA_VAL)
 #define DHD_ISCAN_ON()         (dhd_msg_level & DHD_ISCAN_VAL)
 
-#else /* (defined BCMDBG) || (defined DHD_DEBUG) */
+#else /* DHD_DEBUG */
 
 #define DHD_ERROR(args)        do {if (net_ratelimit()) printf args;} while (0)
 #define DHD_TRACE(args)
@@ -87,7 +87,7 @@
 #define DHD_EVENT_ON()         0
 #define DHD_BTA_ON()           0
 #define DHD_ISCAN_ON()         0
-#endif 
+#endif /* DHD_DEBUG */
 
 #define DHD_LOG(args)
 
index 275407f5ae066dedf7567284fb54b99afa3e6a11..81eef135a16d63c52c721561886f1198ee85fb0e 100644 (file)
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_linux.c,v 1.65.4.9.2.12.2.89 2010/07/21 18:07:11 Exp $
+ * $Id: dhd_linux.c,v 1.65.4.9.2.12.2.104.4.35 2010/11/17 03:13:21 Exp $
  */
 
-
-#ifdef CONFIG_WIFI_CONTROL_FUNC_BCM4319
+#ifdef CONFIG_WIFI_CONTROL_FUNC
 #include <linux/platform_device.h>
 #endif
 #include <typedefs.h>
@@ -48,6 +47,7 @@
 #include <asm/uaccess.h>
 #include <asm/unaligned.h>
 
+#include <wifi_version.h>
 #include <epivers.h>
 #include <bcmutils.h>
 #include <bcmendian.h>
 #include <dhd_bus.h>
 #include <dhd_proto.h>
 #include <dhd_dbg.h>
+#include <wl_iw.h>
+#ifdef CONFIG_HAS_WAKELOCK
+#include <linux/wakelock.h>
+#endif
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
+//#include <linux/wlan_plat.h>
+#include <mach/board.h>
+
+struct semaphore wifi_control_sem;
+
+struct dhd_bus *g_bus;
+
+extern void bcm4329_power_save_exit(void);
+extern void bcm4329_power_save_init(void);
+
+static struct wifi_platform_data *wifi_control_data = NULL;
+static struct resource *wifi_irqres = NULL;
+
+int wifi_get_irq_number(unsigned long *irq_flags_ptr)
+{
+       if (wifi_irqres) {
+               *irq_flags_ptr = wifi_irqres->flags & IRQF_TRIGGER_MASK;
+               return (int)wifi_irqres->start;
+       }
+#ifdef CUSTOM_OOB_GPIO_NUM
+       return CUSTOM_OOB_GPIO_NUM;
+#else
+       return -1;
+#endif
+}
+
+int wifi_set_carddetect(int on)
+{
+       printk("%s = %d\n", __FUNCTION__, on);
+       if (wifi_control_data && wifi_control_data->set_carddetect) {
+               wifi_control_data->set_carddetect(on);
+       }
+       return 0;
+}
+
+int wifi_set_power(int on, unsigned long msec)
+{
+       printk("%s = %d\n", __FUNCTION__, on);
+       if (wifi_control_data && wifi_control_data->set_power) {
+               wifi_control_data->set_power(on);
+       }
+       if (msec)
+               mdelay(msec);
+       return 0;
+}
+
+int wifi_set_reset(int on, unsigned long msec)
+{
+       DHD_TRACE(("%s = %d\n", __FUNCTION__, on));
+       if (wifi_control_data && wifi_control_data->set_reset) {
+               wifi_control_data->set_reset(on);
+       }
+       if (msec)
+               mdelay(msec);
+       return 0;
+}
+
+int wifi_get_mac_addr(unsigned char *buf)
+{
+       DHD_TRACE(("%s\n", __FUNCTION__));
+       if (!buf)
+               return -EINVAL;
+       if (wifi_control_data && wifi_control_data->get_mac_addr) {
+               return wifi_control_data->get_mac_addr(buf);
+       }
+       return -EOPNOTSUPP;
+}
+
+static int wifi_probe(struct platform_device *pdev)
+{
+       struct wifi_platform_data *wifi_ctrl =
+               (struct wifi_platform_data *)(pdev->dev.platform_data);
+
+       DHD_TRACE(("## %s\n", __FUNCTION__));
+       wifi_irqres = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "bcm4329_wlan_irq");
+       wifi_control_data = wifi_ctrl;
+
+       /* make sure power-off */
+       wifi_set_reset(0, 5);
+       wifi_set_power(0, 5);
+
+       wifi_set_power(1, 50);  /* Power On */
+       wifi_set_reset(1, 150); /* Reset */
+       wifi_set_carddetect(1); /* CardDetect (0->1) */
+
+       up(&wifi_control_sem);
+       return 0;
+}
+
+static int wifi_remove(struct platform_device *pdev)
+{
+       struct wifi_platform_data *wifi_ctrl =
+               (struct wifi_platform_data *)(pdev->dev.platform_data);
+
+       DHD_TRACE(("## %s\n", __FUNCTION__));
+       wifi_control_data = wifi_ctrl;
+
+       wifi_set_reset(0, 5);   /* Reset */
+       wifi_set_power(0, 5);   /* Power Off */
+       wifi_set_carddetect(0); /* CardDetect (1->0) */
+
+       up(&wifi_control_sem);
+       return 0;
+}
+static int wifi_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       DHD_TRACE(("##> %s\n", __FUNCTION__));
+       return 0;
+}
+static int wifi_resume(struct platform_device *pdev)
+{
+       DHD_TRACE(("##> %s\n", __FUNCTION__));
+       return 0;
+}
+
+static struct platform_driver wifi_device = {
+       .probe          = wifi_probe,
+       .remove         = wifi_remove,
+       .suspend        = wifi_suspend,
+       .resume         = wifi_resume,
+       .driver         = {
+       .name   = "bcm4329_wlan",
+       }
+};
+
+int wifi_add_dev(void)
+{
+       DHD_TRACE(("## Calling platform_driver_register\n"));
+       return platform_driver_register(&wifi_device);
+}
 
-#include <linux/mmc/card.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/host.h>
+void wifi_del_dev(void)
+{
+       DHD_TRACE(("## Unregister platform_driver_register\n"));
+       platform_driver_unregister(&wifi_device);
+}
+#endif /* defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
 
-int wifi_func_removed = 0;
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
 #include <linux/suspend.h>
@@ -92,12 +228,16 @@ print_tainted()
 #include <wl_iw.h>
 #endif /* defined(CONFIG_WIRELESS_EXT) */
 
+extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len);
+
 #if defined(CONFIG_HAS_EARLYSUSPEND)
 #include <linux/earlysuspend.h>
-extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len);
+#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+
+#ifdef PKT_FILTER_SUPPORT
 extern void dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg);
 extern void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode);
-#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+#endif
 
 /* Interface control information */
 typedef struct dhd_if {
@@ -125,16 +265,18 @@ typedef struct dhd_info {
        /* OS/stack specifics */
        dhd_if_t *iflist[DHD_MAX_IFS];
 
-       struct semaphore proto_sem;
+       struct mutex proto_sem;
        wait_queue_head_t ioctl_resp_wait;
        struct timer_list timer;
        bool wd_timer_valid;
        struct tasklet_struct tasklet;
        spinlock_t      sdlock;
        spinlock_t      txqlock;
+       spinlock_t      dhd_lock;
+
        /* Thread based operation */
        bool threads_only;
-       struct semaphore sdsem;
+       struct mutex sdsem;
        long watchdog_pid;
        struct semaphore watchdog_sem;
        struct completion watchdog_exited;
@@ -142,6 +284,19 @@ typedef struct dhd_info {
        struct semaphore dpc_sem;
        struct completion dpc_exited;
 
+       /* Wakelocks */
+#ifdef CONFIG_HAS_WAKELOCK
+       struct wake_lock wl_wifi;   /* Wifi wakelock */
+       struct wake_lock wl_rxwake; /* Wifi rx wakelock */
+#endif
+       spinlock_t wl_lock;
+       int wl_count;
+       int wl_packet;
+
+       int hang_was_sent; /* flag that message was send at least once */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+       struct mutex wl_start_lock; /* mutex when START called to prevent any other Linux calls */
+#endif
        /* Thread to issue ioctl for multicast */
        long sysioc_pid;
        struct semaphore sysioc_sem;
@@ -160,13 +315,12 @@ typedef struct dhd_info {
 /* Definitions to provide path to the firmware and nvram
  * example nvram_path[MOD_PARAM_PATHLEN]="/projects/wlan/nvram.txt"
  */
-char firmware_path[MOD_PARAM_PATHLEN] = "/etc/firmware/sdio-g-cdc-full11n-reclaim-roml-wme.bin";
-char nvram_path[MOD_PARAM_PATHLEN] = "/etc/firmware/nvram_4319_201008.txt";
+char firmware_path[MOD_PARAM_PATHLEN];
+char nvram_path[MOD_PARAM_PATHLEN];
 
-extern int      wl_control_wl_start(struct net_device *dev);
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
 struct semaphore dhd_registration_sem;
-#define DHD_REGISTRATION_TIMEOUT  8000  /* msec : allowed time to finished dhd registration */
+#define DHD_REGISTRATION_TIMEOUT  12000  /* msec : allowed time to finished dhd registration */
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
 /* load firmware and/or nvram values from the filesystem */
 module_param_string(firmware_path, firmware_path, MOD_PARAM_PATHLEN, 0);
@@ -221,7 +375,7 @@ module_param(dhd_dpc_prio, int, 0);
 extern int dhd_dongle_memsize;
 module_param(dhd_dongle_memsize, int, 0);
 
-/* Contorl fw roaming */
+/* Control fw roaming */
 #ifdef CUSTOMER_HW2
 uint dhd_roam = 0;
 #else
@@ -232,7 +386,7 @@ uint dhd_roam = 1;
 uint dhd_radio_up = 1;
 
 /* Network inteface name */
-char iface_name[IFNAMSIZ];
+char iface_name[IFNAMSIZ] = "wlan0";
 module_param_string(iface_name, iface_name, IFNAMSIZ, 0);
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
@@ -297,9 +451,11 @@ uint dhd_pktgen_len = 0;
 module_param(dhd_pktgen_len, uint, 0);
 #endif
 
-
 /* Version string to report */
 #ifdef DHD_DEBUG
+#ifndef SRCBASE
+#define SRCBASE        "drivers/net/wireless/bcm4329"
+#endif
 #define DHD_COMPILED "\nCompiled in " SRCBASE
 #else
 #define DHD_COMPILED
@@ -331,21 +487,25 @@ static int dhd_toe_set(dhd_info_t *dhd, int idx, uint32 toe_ol);
 static int dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
                              wl_event_msg_t *event_ptr, void **data_ptr);
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) && 1
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
 static int dhd_sleep_pm_callback(struct notifier_block *nfb, unsigned long action, void *ignored)
 {
-       switch (action)
-       {
-               case PM_HIBERNATION_PREPARE:
-               case PM_SUSPEND_PREPARE:
-                       dhd_mmc_suspend = TRUE;
-                       return NOTIFY_OK;
-               case PM_POST_HIBERNATION:
-               case PM_POST_SUSPEND:
-                       dhd_mmc_suspend = FALSE;
-               return NOTIFY_OK;
+       int ret = NOTIFY_DONE;
+
+       switch (action) {
+       case PM_HIBERNATION_PREPARE:
+       case PM_SUSPEND_PREPARE:
+               dhd_mmc_suspend = TRUE;
+               ret = NOTIFY_OK;
+               break;
+       case PM_POST_HIBERNATION:
+       case PM_POST_SUSPEND:
+               dhd_mmc_suspend = FALSE;
+               ret = NOTIFY_OK;
+               break;
        }
-       return 0;
+       smp_mb();
+       return ret;
 }
 
 static struct notifier_block dhd_sleep_pm_notifier = {
@@ -355,12 +515,29 @@ static struct notifier_block dhd_sleep_pm_notifier = {
 extern int register_pm_notifier(struct notifier_block *nb);
 extern int unregister_pm_notifier(struct notifier_block *nb);
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
-       /* && defined(DHD_GPL) */
 
+static void dhd_set_packet_filter(int value, dhd_pub_t *dhd)
+{
+#ifdef PKT_FILTER_SUPPORT
+       DHD_TRACE(("%s: %d\n", __FUNCTION__, value));
+       /* 1 - Enable packet filter, only allow unicast packet to send up */
+       /* 0 - Disable packet filter */
+       if (dhd_pkt_filter_enable) {
+               int i;
 
-#if defined(CONFIG_HAS_EARLYSUSPEND)
+               for (i = 0; i < dhd->pktfilter_count; i++) {
+                       dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]);
+                       dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i],
+                                       value, dhd_master_mode);
+               }
+       }
+#endif
+}
 
-int dhd_set_suspend(int value, dhd_pub_t *dhd)
+
+
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+static int dhd_set_suspend(int value, dhd_pub_t *dhd)
 {
        int power_mode = PM_MAX;
        /* wl_pkt_filter_enable_t       enable_parm; */
@@ -369,87 +546,96 @@ int dhd_set_suspend(int value, dhd_pub_t *dhd)
 #ifdef CUSTOMER_HW2
        uint roamvar = 1;
 #endif /* CUSTOMER_HW2 */
-       int i;
 
-#define htod32(i) i
+       DHD_TRACE(("%s: enter, value = %d in_suspend = %d\n",
+                       __FUNCTION__, value, dhd->in_suspend));
 
        if (dhd && dhd->up) {
-               dhd_os_proto_block(dhd);
-               if (value) {
+               if (value && dhd->in_suspend) {
 
                        /* Kernel suspended */
+                       DHD_TRACE(("%s: force extra Suspend setting \n", __FUNCTION__));
+
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM,
                                (char *)&power_mode, sizeof(power_mode));
 
                        /* Enable packet filter, only allow unicast packet to send up */
-                       if (dhd_pkt_filter_enable) {
-                               for (i = 0; i < dhd->pktfilter_count; i++) {
-                                       dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]);
-                                       dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i],
-                                               1, dhd_master_mode);
-                               }
-                       }
+                       dhd_set_packet_filter(1, dhd);
 
-                       /* set bcn_li_dtim */
+                       /* if dtim skip setup as default force it to wake each thrid dtim
+                        *  for better power saving.
+                        *  Note that side effect is chance to miss BC/MC packet
+                       */
+                       bcn_li_dtim = dhd_get_dtim_skip(dhd);
                        bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
                                4, iovbuf, sizeof(iovbuf));
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 #ifdef CUSTOMER_HW2
-                       /* Disable build-in roaming to allowed ext supplicant to take of romaing */
+                       /* Disable build-in roaming during suspend */
                        bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf, sizeof(iovbuf));
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 #endif /* CUSTOMER_HW2 */
+
                } else {
 
                        /* Kernel resumed  */
+                       DHD_TRACE(("%s: Remove extra suspend setting \n", __FUNCTION__));
+
                        power_mode = PM_FAST;
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_PM, (char *)&power_mode,
                                sizeof(power_mode));
 
                        /* disable pkt filter */
-                       if (dhd_pkt_filter_enable) {
-                               for (i = 0; i < dhd->pktfilter_count; i++) {
-                                       dhd_pktfilter_offload_set(dhd, dhd->pktfilter[i]);
-                                       dhd_pktfilter_offload_enable(dhd, dhd->pktfilter[i],
-                                               0, dhd_master_mode);
-                               }
-                       }
+                       dhd_set_packet_filter(0, dhd);
 
-                       /* set bcn_li_dtim */
-                       bcn_li_dtim = 0;
-                       bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
+                       /* restore pre-suspend setting for dtim_skip */
+                       bcm_mkiovar("bcn_li_dtim", (char *)&dhd->dtim_skip,
                                4, iovbuf, sizeof(iovbuf));
+
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 #ifdef CUSTOMER_HW2
-                       roamvar = 0;
+                       roamvar = dhd_roam;
                        bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf, sizeof(iovbuf));
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf));
 #endif /* CUSTOMER_HW2 */
                }
-               dhd_os_proto_unblock(dhd);
        }
 
        return 0;
 }
 
+static void dhd_suspend_resume_helper(struct dhd_info *dhd, int val)
+{
+       dhd_pub_t *dhdp = &dhd->pub;
+
+       dhd_os_wake_lock(dhdp);
+       dhd_os_proto_block(dhdp);
+       /* Set flag when early suspend was called */
+       dhdp->in_suspend = val;
+       if (!dhdp->suspend_disable_flag)
+               dhd_set_suspend(val, dhdp);
+       dhd_os_proto_unblock(dhdp);
+       dhd_os_wake_unlock(dhdp);
+}
+
 static void dhd_early_suspend(struct early_suspend *h)
 {
-       struct dhd_info *dhdp;
-       dhdp = container_of(h, struct dhd_info, early_suspend);
+       struct dhd_info *dhd = container_of(h, struct dhd_info, early_suspend);
 
        DHD_TRACE(("%s: enter\n", __FUNCTION__));
 
-       dhd_set_suspend(1, &dhdp->pub);
+       if (dhd)
+               dhd_suspend_resume_helper(dhd, 1);
 }
 
 static void dhd_late_resume(struct early_suspend *h)
 {
-       struct dhd_info *dhdp;
-       dhdp = container_of(h, struct dhd_info, early_suspend);
+       struct dhd_info *dhd = container_of(h, struct dhd_info, early_suspend);
 
        DHD_TRACE(("%s: enter\n", __FUNCTION__));
 
-       dhd_set_suspend(0, &dhdp->pub);
+       if (dhd)
+               dhd_suspend_resume_helper(dhd, 0);
 }
 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
 
@@ -573,7 +759,11 @@ static void
 _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 {
        struct net_device *dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+       struct netdev_hw_addr *ha;
+#else
        struct dev_mc_list *mclist;
+#endif
        uint32 allmulti, cnt;
 
        wl_ioctl_t ioc;
@@ -583,15 +773,19 @@ _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
 
        ASSERT(dhd && dhd->iflist[ifidx]);
        dev = dhd->iflist[ifidx]->net;
-       mclist = dev->mc_list;
+
+       netif_addr_lock_bh(dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+       cnt = netdev_mc_count(dev);
+#else
        cnt = dev->mc_count;
+#endif
+       netif_addr_unlock_bh(dev);
 
        /* Determine initial value of allmulti flag */
        allmulti = (dev->flags & IFF_ALLMULTI) ? TRUE : FALSE;
 
        /* Send down the multicast list first. */
-
-
        buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETHER_ADDR_LEN);
        if (!(bufp = buf = MALLOC(dhd->pub.osh, buflen))) {
                DHD_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
@@ -606,10 +800,22 @@ _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
        memcpy(bufp, &cnt, sizeof(cnt));
        bufp += sizeof(cnt);
 
-       for (cnt = 0; mclist && (cnt < dev->mc_count); cnt++, mclist = mclist->next) {
+       netif_addr_lock_bh(dev);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+       netdev_for_each_mc_addr(ha, dev) {
+               if (!cnt)
+                       break;
+               memcpy(bufp, ha->addr, ETHER_ADDR_LEN);
+               bufp += ETHER_ADDR_LEN;
+               cnt--;
+       }
+#else
+       for (mclist = dev->mc_list;(mclist && (cnt > 0)); cnt--, mclist = mclist->next) {
                memcpy(bufp, (void *)mclist->dmi_addr, ETHER_ADDR_LEN);
                bufp += ETHER_ADDR_LEN;
        }
+#endif
+       netif_addr_unlock_bh(dev);
 
        memset(&ioc, 0, sizeof(ioc));
        ioc.cmd = WLC_SET_VAR;
@@ -708,13 +914,18 @@ _dhd_set_mac_address(dhd_info_t *dhd, int ifidx, struct ether_addr *addr)
 
 #ifdef SOFTAP
 extern struct net_device *ap_net_dev;
+/* semaphore that the soft AP CODE waits on */
+extern struct semaphore ap_eth_sema;
 #endif
 
 static void
 dhd_op_if(dhd_if_t *ifp)
 {
-       dhd_info_t      *dhd;
-       int                     ret = 0, err = 0;
+       dhd_info_t *dhd;
+       int ret = 0, err = 0;
+#ifdef SOFTAP
+       unsigned long flags;
+#endif
 
        ASSERT(ifp && ifp->info && ifp->idx);   /* Virtual interfaces only */
 
@@ -749,13 +960,12 @@ dhd_op_if(dhd_if_t *ifp)
                                ret = -EOPNOTSUPP;
                        } else {
 #ifdef SOFTAP
-                                /* semaphore that the soft AP CODE waits on */
-                               extern struct semaphore  ap_eth_sema;
-
+                               flags = dhd_os_spin_lock(&dhd->pub);
                                /* save ptr to wl0.1 netdev for use in wl_iw.c  */
                                ap_net_dev = ifp->net;
                                 /* signal to the SOFTAP 'sleeper' thread, wl0.1 is ready */
                                up(&ap_eth_sema);
+                               dhd_os_spin_unlock(&dhd->pub, flags);
 #endif
                                DHD_TRACE(("\n ==== pid:%x, net_device for if:%s created ===\n\n",
                                        current->pid, ifp->net->name));
@@ -765,7 +975,7 @@ dhd_op_if(dhd_if_t *ifp)
                break;
        case WLC_E_IF_DEL:
                if (ifp->net != NULL) {
-                   DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n", __FUNCTION__));
+                       DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n", __FUNCTION__));
                        netif_stop_queue(ifp->net);
                        unregister_netdev(ifp->net);
                        ret = DHD_DEL_IF;       /* Make sure the free_netdev() is called */
@@ -784,8 +994,10 @@ dhd_op_if(dhd_if_t *ifp)
                dhd->iflist[ifp->idx] = NULL;
                MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
 #ifdef SOFTAP
+               flags = dhd_os_spin_lock(&dhd->pub);
                if (ifp->net == ap_net_dev)
-                       ap_net_dev = NULL;   /*  NULL  SOFTAP global wl0.1 as well */
+                       ap_net_dev = NULL;     /* NULL SOFTAP global as well */
+               dhd_os_spin_unlock(&dhd->pub, flags);
 #endif /*  SOFTAP */
        }
 }
@@ -797,35 +1009,38 @@ _dhd_sysioc_thread(void *data)
        int i;
 #ifdef SOFTAP
        bool in_ap = FALSE;
+       unsigned long flags;
 #endif
 
        DAEMONIZE("dhd_sysioc");
 
        while (down_interruptible(&dhd->sysioc_sem) == 0) {
+               dhd_os_start_lock(&dhd->pub);
+               dhd_os_wake_lock(&dhd->pub);
                for (i = 0; i < DHD_MAX_IFS; i++) {
                        if (dhd->iflist[i]) {
+                               DHD_TRACE(("%s: interface %d\n",__FUNCTION__, i));
 #ifdef SOFTAP
+                               flags = dhd_os_spin_lock(&dhd->pub);
                                in_ap = (ap_net_dev != NULL);
+                               dhd_os_spin_unlock(&dhd->pub, flags);
 #endif /* SOFTAP */
                                if (dhd->iflist[i]->state)
                                        dhd_op_if(dhd->iflist[i]);
 #ifdef SOFTAP
                                if (dhd->iflist[i] == NULL) {
-                                       DHD_TRACE(("\n\n %s: interface %d just been removed,"
-                                               "!\n\n", __FUNCTION__, i));
+                                       DHD_TRACE(("%s: interface %d just been removed!\n\n", __FUNCTION__, i));
                                        continue;
                                }
 
-                               if (in_ap && dhd->set_macaddress)  {
-                                       DHD_TRACE(("attempt to set MAC for %s in AP Mode,"
-                                               "blocked. \n", dhd->iflist[i]->net->name));
+                               if (in_ap && dhd->set_macaddress) {
+                                       DHD_TRACE(("attempt to set MAC for %s in AP Mode blocked.\n", dhd->iflist[i]->net->name));
                                        dhd->set_macaddress = FALSE;
                                        continue;
                                }
 
                                if (in_ap && dhd->set_multicast)  {
-                                       DHD_TRACE(("attempt to set MULTICAST list for %s"
-                                        "in AP Mode, blocked. \n", dhd->iflist[i]->net->name));
+                                       DHD_TRACE(("attempt to set MULTICAST list for %s in AP Mode blocked.\n", dhd->iflist[i]->net->name));
                                        dhd->set_multicast = FALSE;
                                        continue;
                                }
@@ -840,7 +1055,10 @@ _dhd_sysioc_thread(void *data)
                                }
                        }
                }
+               dhd_os_wake_unlock(&dhd->pub);
+               dhd_os_start_unlock(&dhd->pub);
        }
+       DHD_TRACE(("%s: stopped\n",__FUNCTION__));
        complete_and_exit(&dhd->sysioc_exited, 0);
 }
 
@@ -853,6 +1071,7 @@ dhd_set_mac_address(struct net_device *dev, void *addr)
        struct sockaddr *sa = (struct sockaddr *)addr;
        int ifidx;
 
+       DHD_TRACE(("%s: Enter\n",__FUNCTION__));
        ifidx = dhd_net2idx(dhd, dev);
        if (ifidx == DHD_BAD_IF)
                return -1;
@@ -871,6 +1090,7 @@ dhd_set_multicast_list(struct net_device *dev)
        dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
        int ifidx;
 
+       DHD_TRACE(("%s: Enter\n",__FUNCTION__));
        ifidx = dhd_net2idx(dhd, dev);
        if (ifidx == DHD_BAD_IF)
                return;
@@ -913,7 +1133,6 @@ dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pktbuf)
 #ifdef BCMDBUS
        ret = dbus_send_pkt(dhdp->dbus, pktbuf, NULL /* pktinfo */);
 #else
-       WAKE_LOCK_TIMEOUT(dhdp, WAKE_LOCK_TMOUT, 25);
        ret = dhd_bus_txdata(dhdp->bus, pktbuf);
 #endif /* BCMDBUS */
 
@@ -930,16 +1149,19 @@ dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
 
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
+       dhd_os_wake_lock(&dhd->pub);
+
        /* Reject if down */
        if (!dhd->pub.up || (dhd->pub.busstate == DHD_BUS_DOWN)) {
-               DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d \n",
-                       __FUNCTION__, dhd->pub.up, dhd->pub.busstate));
+               DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n",
+                        __FUNCTION__, dhd->pub.up, dhd->pub.busstate));
                netif_stop_queue(net);
                /* Send Event when bus down detected during data session */
                if (dhd->pub.busstate == DHD_BUS_DOWN)  {
-                       DHD_ERROR(("%s: Event RELOAD send up\n", __FUNCTION__));
-                       wl_iw_send_priv_event(net, "RELOAD");
+                       DHD_ERROR(("%s: Event HANG send up\n", __FUNCTION__));
+                       net_os_send_hang_message(net);
                }
+               dhd_os_wake_unlock(&dhd->pub);
                return -ENODEV;
        }
 
@@ -947,6 +1169,7 @@ dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
        if (ifidx == DHD_BAD_IF) {
                DHD_ERROR(("%s: bad ifidx %d\n", __FUNCTION__, ifidx));
                netif_stop_queue(net);
+               dhd_os_wake_unlock(&dhd->pub);
                return -ENODEV;
        }
 
@@ -978,13 +1201,14 @@ dhd_start_xmit(struct sk_buff *skb, struct net_device *net)
 
        ret = dhd_sendpkt(&dhd->pub, ifidx, pktbuf);
 
-
 done:
        if (ret)
                dhd->pub.dstats.tx_dropped++;
        else
                dhd->pub.tx_packets++;
 
+       dhd_os_wake_unlock(&dhd->pub);
+
        /* Return ok: we always eat the packet */
        return 0;
 }
@@ -1101,6 +1325,7 @@ dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *pktbuf, int numpkt)
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) */
                }
        }
+       dhd_os_wake_lock_timeout_enable(dhdp);
 }
 
 void
@@ -1167,7 +1392,6 @@ static int
 dhd_watchdog_thread(void *data)
 {
        dhd_info_t *dhd = (dhd_info_t *)data;
-       WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_WATCHDOG, "dhd_watchdog_thread");
 
        /* This thread doesn't need any user-level access,
         * so get rid of all our resources
@@ -1186,25 +1410,26 @@ dhd_watchdog_thread(void *data)
        /* Run until signal received */
        while (1) {
                if (down_interruptible (&dhd->watchdog_sem) == 0) {
+                       dhd_os_sdlock(&dhd->pub);
                        if (dhd->pub.dongle_reset == FALSE) {
-                               WAKE_LOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
+                               DHD_TIMER(("%s:\n", __FUNCTION__));
                                /* Call the bus module watchdog */
                                dhd_bus_watchdog(&dhd->pub);
-                               WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_WATCHDOG);
-                       }
-                       /* Count the tick for reference */
-                       dhd->pub.tickcnt++;
 
-                       /* Reschedule the watchdog */
-                       if (dhd->wd_timer_valid) {
-                               mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
+                               /* Count the tick for reference */
+                               dhd->pub.tickcnt++;
+
+                               /* Reschedule the watchdog */
+                               if (dhd->wd_timer_valid)
+                                       mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
                        }
-               }
-               else
+                       dhd_os_sdunlock(&dhd->pub);
+                       dhd_os_wake_unlock(&dhd->pub);
+               } else {
                        break;
+               }
        }
 
-       WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_WATCHDOG);
        complete_and_exit(&dhd->watchdog_exited, 0);
 }
 
@@ -1213,11 +1438,18 @@ dhd_watchdog(ulong data)
 {
        dhd_info_t *dhd = (dhd_info_t *)data;
 
+       dhd_os_wake_lock(&dhd->pub);
+       if (dhd->pub.dongle_reset) {
+               dhd_os_wake_unlock(&dhd->pub);
+               return;
+       }
+
        if (dhd->watchdog_pid >= 0) {
                up(&dhd->watchdog_sem);
                return;
        }
 
+       dhd_os_sdlock(&dhd->pub);
        /* Call the bus module watchdog */
        dhd_bus_watchdog(&dhd->pub);
 
@@ -1227,6 +1459,8 @@ dhd_watchdog(ulong data)
        /* Reschedule the watchdog */
        if (dhd->wd_timer_valid)
                mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
+       dhd_os_sdunlock(&dhd->pub);
+       dhd_os_wake_unlock(&dhd->pub);
 }
 
 static int
@@ -1234,7 +1468,6 @@ dhd_dpc_thread(void *data)
 {
        dhd_info_t *dhd = (dhd_info_t *)data;
 
-       WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_DPC, "dhd_dpc_thread");
        /* This thread doesn't need any user-level access,
         * so get rid of all our resources
         */
@@ -1254,22 +1487,21 @@ dhd_dpc_thread(void *data)
                if (down_interruptible(&dhd->dpc_sem) == 0) {
                        /* Call bus dpc unless it indicated down (then clean stop) */
                        if (dhd->pub.busstate != DHD_BUS_DOWN) {
-                               WAKE_LOCK(&dhd->pub, WAKE_LOCK_DPC);
                                if (dhd_bus_dpc(dhd->pub.bus)) {
                                        up(&dhd->dpc_sem);
-                                       WAKE_LOCK_TIMEOUT(&dhd->pub, WAKE_LOCK_TMOUT, 25);
                                }
-                               WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_DPC);
+                               else {
+                                       dhd_os_wake_unlock(&dhd->pub);
+                               }
                        } else {
                                dhd_bus_stop(dhd->pub.bus, TRUE);
+                               dhd_os_wake_unlock(&dhd->pub);
                        }
                }
                else
                        break;
        }
 
-       WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_DPC);
-
        complete_and_exit(&dhd->dpc_exited, 0);
 }
 
@@ -1294,6 +1526,7 @@ dhd_sched_dpc(dhd_pub_t *dhdp)
 {
        dhd_info_t *dhd = (dhd_info_t *)dhdp->info;
 
+       dhd_os_wake_lock(dhdp);
        if (dhd->dpc_pid >= 0) {
                up(&dhd->dpc_sem);
                return;
@@ -1515,28 +1748,40 @@ dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
        uint driver = 0;
        int ifidx;
        bool is_set_key_cmd;
-       
+       int ret;
+
+       dhd_os_wake_lock(&dhd->pub);
+
        ifidx = dhd_net2idx(dhd, net);
        DHD_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __FUNCTION__, ifidx, cmd));
 
-       if (ifidx == DHD_BAD_IF)
+       if (ifidx == DHD_BAD_IF) {
+               dhd_os_wake_unlock(&dhd->pub);
                return -1;
+       }
 
 #if defined(CONFIG_WIRELESS_EXT)
        /* linux wireless extensions */
        if ((cmd >= SIOCIWFIRST) && (cmd <= SIOCIWLAST)) {
                /* may recurse, do NOT lock */
-               return wl_iw_ioctl(net, ifr, cmd);
+               ret = wl_iw_ioctl(net, ifr, cmd);
+               dhd_os_wake_unlock(&dhd->pub);
+               return ret;
        }
 #endif /* defined(CONFIG_WIRELESS_EXT) */
 
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 2)
-       if (cmd == SIOCETHTOOL)
-               return (dhd_ethtool(dhd, (void*)ifr->ifr_data));
+       if (cmd == SIOCETHTOOL) {
+               ret = dhd_ethtool(dhd, (void*)ifr->ifr_data);
+               dhd_os_wake_unlock(&dhd->pub);
+               return ret;
+       }
 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 2) */
 
-       if (cmd != SIOCDEVPRIVATE)
+       if (cmd != SIOCDEVPRIVATE) {
+               dhd_os_wake_unlock(&dhd->pub);
                return -EOPNOTSUPP;
+       }
 
        memset(&ioc, 0, sizeof(ioc));
 
@@ -1581,7 +1826,6 @@ dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 
        /* check for local dhd ioctl and handle it */
        if (driver == DHD_IOCTL_MAGIC) {
-               printk("%s: Is local dhd ioctl\n", __func__);
                bcmerror = dhd_ioctl((void *)&dhd->pub, &ioc, buf, buflen);
                if (bcmerror)
                        dhd->pub.bcmerror = bcmerror;
@@ -1589,9 +1833,8 @@ 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,__FUNCTION__\n", __FUNCTION__));
+       if (dhd->pub.busstate != DHD_BUS_DATA) {
+               DHD_ERROR(("%s DONGLE_DOWN\n", __FUNCTION__));
                bcmerror = BCME_DONGLE_DOWN;
                goto done;
        }
@@ -1612,18 +1855,16 @@ dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
        if (is_set_key_cmd) {
                dhd_wait_pend8021x(net);
        }
-       WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_IOCTL, "dhd_ioctl_entry");
-       WAKE_LOCK(&dhd->pub, WAKE_LOCK_IOCTL);
 
        bcmerror = dhd_prot_ioctl(&dhd->pub, ifidx, (wl_ioctl_t *)&ioc, buf, buflen);
 
-       WAKE_UNLOCK(&dhd->pub, WAKE_LOCK_IOCTL);
-       WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_IOCTL);
-       if (bcmerror == -ETIMEDOUT) {
-               DHD_ERROR(("%s: Event RELOAD send up\n", __FUNCTION__));
-               wl_iw_send_priv_event(net, "RELOAD");
-       }
 done:
+       if ((bcmerror == -ETIMEDOUT) || ((dhd->pub.busstate == DHD_BUS_DOWN) &&
+                       (!dhd->pub.dongle_reset))) {
+               DHD_ERROR(("%s: Event HANG send up\n", __FUNCTION__));
+               net_os_send_hang_message(net);
+       }
+
        if (!bcmerror && buf && ioc.buf) {
                if (copy_to_user(ioc.buf, buf, buflen))
                        bcmerror = -EFAULT;
@@ -1632,6 +1873,8 @@ done:
        if (buf)
                MFREE(dhd->pub.osh, buf, buflen);
 
+       dhd_os_wake_unlock(&dhd->pub);
+
        return OSL_ERROR(bcmerror);
 }
 
@@ -1641,7 +1884,7 @@ dhd_stop(struct net_device *net)
 #if !defined(IGNORE_ETH0_DOWN)
        dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(net);
 
-       DHD_TRACE(("%s: Enter\n", __FUNCTION__));
+       DHD_TRACE(("%s: Enter %s\n", __FUNCTION__, net->name));
        if (dhd->pub.up == 0) {
                return 0;
        }
@@ -1664,14 +1907,21 @@ dhd_open(struct net_device *net)
 #ifdef TOE
        uint32 toe_ol;
 #endif
-       int ifidx = dhd_net2idx(dhd, net);
-       int32 ret = 0;
-
-       DHD_TRACE(("%s: ifidx %d\n", __FUNCTION__, ifidx));
+       int ifidx;
 
        /*  Force start if ifconfig_up gets called before START command */
        wl_control_wl_start(net);
 
+       ifidx = dhd_net2idx(dhd, net);
+        if (ifidx == DHD_BAD_IF)
+                return -1;
+       DHD_TRACE(("%s: ifidx %d\n", __FUNCTION__, ifidx));
+
+       if ((dhd->iflist[ifidx]) && (dhd->iflist[ifidx]->state == WLC_E_IF_DEL)) {
+               DHD_ERROR(("%s: Error: called when IF already deleted\n", __FUNCTION__));
+               return -1;
+       }
+
        if (ifidx == 0) { /* do it only for primary eth0 */
 
                atomic_set(&dhd->pend_8021x_cnt, 0);
@@ -1690,9 +1940,8 @@ dhd_open(struct net_device *net)
        netif_start_queue(net);
        dhd->pub.up = 1;
 
-
        OLD_MOD_INC_USE_COUNT;
-       return ret;
+       return 0;
 }
 
 osl_t *
@@ -1708,7 +1957,7 @@ dhd_osl_detach(osl_t *osh)
                DHD_ERROR(("%s: MEMORY LEAK %d bytes\n", __FUNCTION__, MALLOCED(osh)));
        }
        osl_detach(osh);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && 1
        up(&dhd_registration_sem);
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
 }
@@ -1812,19 +2061,17 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
                if ((ch > '9' || ch < '0') && (len < IFNAMSIZ - 2))
                        strcat(net->name, "%d");
        }
-        
-        /* we rename the netdevice interface name wlan0 */
-        dev_alloc_name(net, "wlan%d");
 
        if (dhd_add_if(dhd, 0, (void *)net, net->name, NULL, 0, 0) == DHD_BAD_IF)
                goto fail;
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
        net->open = NULL;
 #else
        net->netdev_ops = NULL;
 #endif
-       init_MUTEX(&dhd->proto_sem);
+
+       mutex_init(&dhd->proto_sem);
        /* Initialize other structure content */
        init_waitqueue_head(&dhd->ioctl_resp_wait);
        init_waitqueue_head(&dhd->ctrl_wait);
@@ -1832,7 +2079,19 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
        /* Initialize the spinlocks */
        spin_lock_init(&dhd->sdlock);
        spin_lock_init(&dhd->txqlock);
-
+       spin_lock_init(&dhd->dhd_lock);
+
+       /* Initialize Wakelock stuff */
+       spin_lock_init(&dhd->wl_lock);
+       dhd->wl_count = 0;
+       dhd->wl_packet = 0;
+#ifdef CONFIG_HAS_WAKELOCK
+       wake_lock_init(&dhd->wl_wifi, WAKE_LOCK_SUSPEND, "wlan_wake");
+       wake_lock_init(&dhd->wl_rxwake, WAKE_LOCK_SUSPEND, "wlan_rx_wake");
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+       mutex_init(&dhd->wl_start_lock);
+#endif
        /* Link to info module */
        dhd->pub.info = dhd;
 
@@ -1853,14 +2112,13 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
        }
 #endif /* defined(CONFIG_WIRELESS_EXT) */
 
-
        /* Set up the watchdog timer */
        init_timer(&dhd->timer);
        dhd->timer.data = (ulong)dhd;
        dhd->timer.function = dhd_watchdog;
 
        /* Initialize thread based operation and lock */
-       init_MUTEX(&dhd->sdsem);
+       mutex_init(&dhd->sdsem);
        if ((dhd_watchdog_prio >= 0) && (dhd_dpc_prio >= 0)) {
                dhd->threads_only = TRUE;
        }
@@ -1901,16 +2159,12 @@ dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
         */
        memcpy(netdev_priv(net), &dhd, sizeof(dhd));
 
-#if defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
        g_bus = bus;
 #endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) && 1
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
        register_pm_notifier(&dhd_sleep_pm_notifier);
 #endif /*  (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
-       /* && defined(DHD_GPL) */
-       /* Init lock suspend to prevent kernel going to suspend */
-       WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_TMOUT, "dhd_wake_lock");
-       WAKE_LOCK_INIT(&dhd->pub, WAKE_LOCK_LINK_DOWN_TMOUT, "dhd_wake_lock_link_dw_event");
 
 #ifdef CONFIG_HAS_EARLYSUSPEND
        dhd->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 20;
@@ -1943,23 +2197,15 @@ dhd_bus_start(dhd_pub_t *dhdp)
        ASSERT(dhd);
 
        DHD_TRACE(("%s: \n", __FUNCTION__));
-       printk ("%s: firmware downloading. firmware = %s nvram = %s\n", __FUNCTION__, fw_path, nv_path);
 
        /* try to download image and nvram to the dongle */
        if  (dhd->pub.busstate == DHD_BUS_DOWN) {
-               WAKE_LOCK_INIT(dhdp, WAKE_LOCK_DOWNLOAD, "dhd_bus_start");
-               WAKE_LOCK(dhdp, WAKE_LOCK_DOWNLOAD);
                if (!(dhd_bus_download_firmware(dhd->pub.bus, dhd->pub.osh,
                                                fw_path, nv_path))) {
                        DHD_ERROR(("%s: dhdsdio_probe_download failed. firmware = %s nvram = %s\n",
                                   __FUNCTION__, fw_path, nv_path));
-                       WAKE_UNLOCK(dhdp, WAKE_LOCK_DOWNLOAD);
-                       WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_DOWNLOAD);
                        return -1;
                }
-
-               WAKE_UNLOCK(dhdp, WAKE_LOCK_DOWNLOAD);
-               WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_DOWNLOAD);
        }
 
        /* Start the watchdog timer */
@@ -1974,8 +2220,8 @@ dhd_bus_start(dhd_pub_t *dhdp)
 #if defined(OOB_INTR_ONLY)
        /* Host registration for OOB interrupt */
        if (bcmsdh_register_oob_intr(dhdp)) {
-               del_timer(&dhd->timer);
                dhd->wd_timer_valid = FALSE;
+               del_timer_sync(&dhd->timer);
                DHD_ERROR(("%s Host failed to resgister for OOB\n", __FUNCTION__));
                return -ENODEV;
        }
@@ -1986,8 +2232,8 @@ dhd_bus_start(dhd_pub_t *dhdp)
 
        /* If bus is not ready, can't come up */
        if (dhd->pub.busstate != DHD_BUS_DATA) {
-               del_timer(&dhd->timer);
                dhd->wd_timer_valid = FALSE;
+               del_timer_sync(&dhd->timer);
                DHD_ERROR(("%s failed bus is not ready\n", __FUNCTION__));
                return -ENODEV;
        }
@@ -2015,6 +2261,13 @@ dhd_bus_start(dhd_pub_t *dhdp)
        setbit(dhdp->eventmask, WLC_E_TXFAIL);
        setbit(dhdp->eventmask, WLC_E_JOIN_START);
        setbit(dhdp->eventmask, WLC_E_SCAN_COMPLETE);
+       setbit(dhdp->eventmask, WLC_E_RELOAD);
+#ifdef PNO_SUPPORT
+       setbit(dhdp->eventmask, WLC_E_PFN_NET_FOUND);
+#endif /* PNO_SUPPORT */
+
+/* enable dongle roaming event */
+       setbit(dhdp->eventmask, WLC_E_ROAM);
 
        dhdp->pktfilter_count = 1;
        /* Setup filter to allow only unicast */
@@ -2052,7 +2305,7 @@ dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf, uint cmd_len, in
        return ret;
 }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
 static struct net_device_ops dhd_ops_pri = {
        .ndo_open = dhd_open,
        .ndo_stop = dhd_stop,
@@ -2060,7 +2313,7 @@ static struct net_device_ops dhd_ops_pri = {
        .ndo_do_ioctl = dhd_ioctl_entry,
        .ndo_start_xmit = dhd_start_xmit,
        .ndo_set_mac_address = dhd_set_mac_address,
-       .ndo_set_multicast_list = dhd_set_multicast_list
+       .ndo_set_multicast_list = dhd_set_multicast_list,
 };
 
 static struct net_device_ops dhd_ops_virt = {
@@ -2068,9 +2321,10 @@ static struct net_device_ops dhd_ops_virt = {
        .ndo_do_ioctl = dhd_ioctl_entry,
        .ndo_start_xmit = dhd_start_xmit,
        .ndo_set_mac_address = dhd_set_mac_address,
-       .ndo_set_multicast_list = dhd_set_multicast_list
+       .ndo_set_multicast_list = dhd_set_multicast_list,
 };
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)) */
+#endif
+
 int
 dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 {
@@ -2081,11 +2335,10 @@ dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
        DHD_TRACE(("%s: ifidx %d\n", __FUNCTION__, ifidx));
 
        ASSERT(dhd && dhd->iflist[ifidx]);
-
        net = dhd->iflist[ifidx]->net;
-       ASSERT(net);
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+       ASSERT(net);
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
        ASSERT(!net->open);
        net->get_stats = dhd_get_stats;
        net->do_ioctl = dhd_ioctl_entry;
@@ -2098,7 +2351,7 @@ dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
        net->netdev_ops = &dhd_ops_virt;
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
                net->open = dhd_open;
                net->stop = dhd_stop;
 #else
@@ -2111,14 +2364,12 @@ dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
        if (ifidx != 0) {
                /* for virtual interfaces use the primary MAC  */
                memcpy(temp_addr, dhd->pub.mac.octet, ETHER_ADDR_LEN);
-
        }
 
        if (ifidx == 1) {
                DHD_TRACE(("%s ACCESS POINT MAC: \n", __FUNCTION__));
                /*  ACCESSPOINT INTERFACE CASE */
-               temp_addr[0] |= 0X02;  /* set bit 2 , - Locally Administered address  */
-
+               temp_addr[0] |= 0x02;  /* set bit 2 , - Locally Administered address  */
        }
        net->hard_header_len = ETH_HLEN + dhd->pub.hdrlen;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
@@ -2134,7 +2385,6 @@ dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 #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, ETHER_ADDR_LEN);
@@ -2148,7 +2398,8 @@ dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
               dhd->pub.mac.octet[0], dhd->pub.mac.octet[1], dhd->pub.mac.octet[2],
               dhd->pub.mac.octet[3], dhd->pub.mac.octet[4], dhd->pub.mac.octet[5]);
 
-#if defined(CONFIG_WIRELESS_EXT) && !defined(CSCAN)
+#if defined(CONFIG_WIRELESS_EXT)
+#if defined(CONFIG_FIRST_SCAN)
 #ifdef SOFTAP
        if (ifidx == 0)
                /* Don't call for SOFTAP Interface in SOFTAP MODE */
@@ -2156,16 +2407,16 @@ dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
 #else
                wl_iw_iscan_set_scan_broadcast_prep(net, 1);
 #endif /* SOFTAP */
+#endif /* CONFIG_FIRST_SCAN */
 #endif /* CONFIG_WIRELESS_EXT */
 
-
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        up(&dhd_registration_sem);
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
        return 0;
 
 fail:
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
        net->open = NULL;
 #else
        net->netdev_ops = NULL;
@@ -2193,8 +2444,8 @@ dhd_bus_detach(dhd_pub_t *dhdp)
 #endif /* defined(OOB_INTR_ONLY) */
 
                        /* Clear the watchdog timer */
-                       del_timer(&dhd->timer);
                        dhd->wd_timer_valid = FALSE;
+                       del_timer_sync(&dhd->timer);
                }
        }
 }
@@ -2213,16 +2464,28 @@ dhd_detach(dhd_pub_t *dhdp)
                        int i;
 
 #if defined(CONFIG_HAS_EARLYSUSPEND)
-                       unregister_early_suspend(&dhd->early_suspend);
+                       if (dhd->early_suspend.suspend)
+                               unregister_early_suspend(&dhd->early_suspend);
 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+#if defined(CONFIG_WIRELESS_EXT)
+                       /* Attach and link in the iw */
+                       wl_iw_detach();
+#endif
+                       if (dhd->sysioc_pid >= 0) {
+                               KILL_PROC(dhd->sysioc_pid, SIGTERM);
+                               wait_for_completion(&dhd->sysioc_exited);
+                       }
 
                        for (i = 1; i < DHD_MAX_IFS; i++)
-                               if (dhd->iflist[i])
-                                       dhd_del_if(dhd, i);
+                               if (dhd->iflist[i]) {
+                                       dhd->iflist[i]->state = WLC_E_IF_DEL;
+                                       dhd->iflist[i]->idx = i;
+                                       dhd_op_if(dhd->iflist[i]);
+                               }
 
                        ifp = dhd->iflist[0];
                        ASSERT(ifp);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31))
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
                        if (ifp->net->open) {
 #else
                        if (ifp->net->netdev_ops == &dhd_ops_pri) {
@@ -2231,72 +2494,61 @@ dhd_detach(dhd_pub_t *dhdp)
                                unregister_netdev(ifp->net);
                        }
 
+                       if (dhd->watchdog_pid >= 0)
+                       {
+                               KILL_PROC(dhd->watchdog_pid, SIGTERM);
+                               wait_for_completion(&dhd->watchdog_exited);
+                       }
 
-               if (dhd->watchdog_pid >= 0)
-               {
-                       KILL_PROC(dhd->watchdog_pid, SIGTERM);
-                       wait_for_completion(&dhd->watchdog_exited);
-               }
-
-               if (dhd->dpc_pid >= 0)
-               {
-                       KILL_PROC(dhd->dpc_pid, SIGTERM);
-                       wait_for_completion(&dhd->dpc_exited);
-               }
-               else
-               tasklet_kill(&dhd->tasklet);
-
-               if (dhd->sysioc_pid >= 0) {
-                       KILL_PROC(dhd->sysioc_pid, SIGTERM);
-                       wait_for_completion(&dhd->sysioc_exited);
-               }
-
-               dhd_bus_detach(dhdp);
-
-               if (dhdp->prot)
-                       dhd_prot_detach(dhdp);
+                       if (dhd->dpc_pid >= 0)
+                       {
+                               KILL_PROC(dhd->dpc_pid, SIGTERM);
+                               wait_for_completion(&dhd->dpc_exited);
+                       }
+                       else
+                               tasklet_kill(&dhd->tasklet);
 
-#if defined(CONFIG_WIRELESS_EXT)
-               /* Attach and link in the iw */
-               wl_iw_detach();
-#endif
+                       dhd_bus_detach(dhdp);
 
+                       if (dhdp->prot)
+                               dhd_prot_detach(dhdp);
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) && 1
-               unregister_pm_notifier(&dhd_sleep_pm_notifier);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
+                       unregister_pm_notifier(&dhd_sleep_pm_notifier);
 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
-       /* && defined(DHD_GPL) */
-               WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_TMOUT);
-               WAKE_LOCK_DESTROY(dhdp, WAKE_LOCK_LINK_DOWN_TMOUT);
-               free_netdev(ifp->net);
-               MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
-               MFREE(dhd->pub.osh, dhd, sizeof(*dhd));
+                       free_netdev(ifp->net);
+#ifdef CONFIG_HAS_WAKELOCK
+                       wake_lock_destroy(&dhd->wl_wifi);
+                       wake_lock_destroy(&dhd->wl_rxwake);
+#endif
+                       MFREE(dhd->pub.osh, ifp, sizeof(*ifp));
+                       MFREE(dhd->pub.osh, dhd, sizeof(*dhd));
+               }
        }
 }
-}
-static void 
-dhd_module_cleanup(void)
+
+void
+rockchip_wifi_exit_module(void)
 {
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
-       printk("hojie: dhd_module_cleanup()\n");
-
        dhd_bus_unregister();
-#if defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
        wifi_del_dev();
 #endif
        /* Call customer gpio to turn off power with WL_REG_ON signal */
        dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF);
+       bcm4329_power_save_exit();
 }
 
-
-static int 
-dhd_module_init(void)
+int
+rockchip_wifi_init_module(void)
 {
        int error;
 
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
+       printk("BCM4319 Wi-Fi driver (Powered by Rockchip,Ver %s) init.\n", BCM4319_DRV_VERSION);
        /* Sanity check on the module parameters */
        do {
                /* Both watchdog and DPC as tasklets are ok */
@@ -2310,30 +2562,30 @@ dhd_module_init(void)
                DHD_ERROR(("Invalid module parameters.\n"));
                return -EINVAL;
        } while (0);
+
        /* Call customer gpio to turn on power with WL_REG_ON signal */
        dhd_customer_gpio_wlan_ctrl(WLAN_POWER_ON);
 
-#if defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
        sema_init(&wifi_control_sem, 0);
 
        error = wifi_add_dev();
        if (error) {
                DHD_ERROR(("%s: platform_driver_register failed\n", __FUNCTION__));
-               goto faild;
+               goto fail_0;
        }
 
        /* Waiting callback after platform_driver_register is done or exit with error */
-       if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(1000)) != 0) {
-               printk("%s: platform_driver_register timeout\n", __FUNCTION__);
-               /* renove device */
-               wifi_del_dev();
-               goto faild;
+       if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(5000)) != 0) {
+               error = -EINVAL;
+               DHD_ERROR(("%s: platform_driver_register timeout\n", __FUNCTION__));
+               goto fail_1;
        }
-#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319) */
+#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        sema_init(&dhd_registration_sem, 0);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
+#endif 
 
        error = dhd_bus_register();
 
@@ -2341,11 +2593,9 @@ dhd_module_init(void)
                printf("\n%s\n", dhd_version);
        else {
                DHD_ERROR(("%s: sdio_register_driver failed\n", __FUNCTION__));
-               goto faild;
+               goto fail_1;
        }
-
-//#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-#if 0
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        /*
         * Wait till MMC sdio_register_driver callback called and made driver attach.
         * It's needed to make sync up exit from dhd insmod  and
@@ -2354,263 +2604,59 @@ dhd_module_init(void)
        if (down_timeout(&dhd_registration_sem,  msecs_to_jiffies(DHD_REGISTRATION_TIMEOUT)) != 0) {
                error = -EINVAL;
                DHD_ERROR(("%s: sdio_register_driver timeout\n", __FUNCTION__));
-               dhd_bus_unregister();
+               goto fail_2;
        }
 #endif
+       bcm4329_power_save_init();
+
        return error;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
+fail_2:
+       dhd_bus_unregister();
+#endif
+fail_1:
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
+       wifi_del_dev();
+fail_0:
+#endif /* defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
 
-faild:
-       /* turn off power and exit */
+       /* Call customer gpio to turn off power with WL_REG_ON signal */
        dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF);
-       return -EINVAL;
-}
 
-//hojie: 2010.10.11
-//for wifi power control
-
-//#if (ANDROID_POWER_SAVE == 1)
-#if 0
-//#include <linux/android_power.h>
-//#include <linux/suspend.h>
-//android_suspend_lock_t wifi_android_lock;
+       return error;
+}
 
-/*
- * Suspend request from android power manager.
- */
-int wifi_suspend(suspend_state_t state)
+//module_init(dhd_module_init);
+//module_exit(dhd_module_cleanup);
+int mv88w8686_if_sdio_init_module(void)
 {
-       printk("System want WIFI to suspend.\n");
-       printk("Not yet implemented.\n");
-       return 0;
-       struct lbs_private *priv = lbs_wifi_priv;
-       
-       if (priv == NULL)
-       {
-           printk("WiFi is disabled for now.\n");
-           return 0;
-       }
-       
-       if (wifi_ps_status == WIFI_PS_DRV_SLEEP)
-       {
-               printk("WiFi is in driver sleep already.\n");
-               return 0;
-       }
-       else /* This should be never occured. */
-/*     {
-           printk("ERROR: WiFi is active for now!!!!!!!!!!\n");
-           return 1;
-       }
-*/
+       return rockchip_wifi_init_module();
 }
 
-
-void wifi_resume(void)
+void mv88w8686_if_sdio_exit_module(void)
 {
-    printk("Android want wifi to be resumed.\n");
+       rockchip_wifi_exit_module();
 }
 
-#endif //(ANDROID_POWER_SAVE == 1)
+EXPORT_SYMBOL(rockchip_wifi_init_module);
+EXPORT_SYMBOL(rockchip_wifi_exit_module);
+EXPORT_SYMBOL(mv88w8686_if_sdio_init_module);
+EXPORT_SYMBOL(mv88w8686_if_sdio_exit_module);
 
-//#include "wifi_power.h"
 
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)
-extern int rk29sdk_wifi_set_carddetect(int val);
-#endif
-
-extern struct mmc_host *wifi_mmc_host;
-extern struct sdio_func *wifi_sdio_func;
-
-extern int wifi_turn_on_card(int module);
-extern int wifi_turn_off_card(void);
-
-#include "wifi_version.h"
-
-int rockchip_wifi_init_module(void)
-{
-       int ret = 0, timeout;
-
-//     printk("Broadcom BCM4319 WiFi driver (Ver %s) init.\n", "0.99");
-//     return dhd_module_init();
-
-       wifi_sdio_func = NULL;
-    wifi_func_removed = 0;
-//     wifi_no_power_gpio = 0;
-       
-       /* Make sure we are in awake. -- Yongle Lai */
-//     wifi_ps_status = WIFI_PS_AWAKE;
-       
-       printk("Broadcom BCM4319 WiFi (Powered by Rockchip, Ver %s).\n", BCM4319_DRV_VERSION);
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-       if (wifi_mmc_host == NULL)
-       {
-               printk("SDIO host (mmc1) for WiFi is inactive.\n");
-               return -ENODEV;
-       }
-#endif
-
-       ret = dhd_module_init();
-
-       if(ret) {
-               printk("dhd_module_init() fail, ret = %d\n", ret);
-               return ret;
-       }
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-       if (wifi_mmc_host->bus_ops != NULL) /* mmc/card is attached already. */
-       {
-               printk("SDIO maybe be attached already.\n");
-       //      wifi_no_power_gpio = 1;
-               //return 0;
-               goto wait_wifi;
-       }
-#endif 
-       wifi_turn_on_card(2);
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-    mmc_detect_change(wifi_mmc_host, 1);
-#else
-    rk29sdk_wifi_set_carddetect(1);
-#endif
-
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-wait_wifi:
-#endif
-       //printk("Waiting for SDIO card to be attached.\n");
-       for (timeout = 50; timeout >=0; timeout--)
-       {
-               if (wifi_sdio_func != NULL)
-                       break;
-               msleep(100);
-       }
-       if (timeout <= 0)
-       {
-               printk("No WiFi function card has been attached (5s).\n");
-               
-       //      sdio_unregister_driver(&if_sdio_driver);
-               dhd_module_cleanup();
-               
-               wifi_turn_off_card();
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-        mmc_detect_change(wifi_mmc_host, 1);
-#else
-        rk29sdk_wifi_set_carddetect(0);
-#endif
-               return -ENODEV;
-       }
-       printk("%s: timeout = %d (interval = 100 ms)\n", __func__, timeout);
-
-//#endif
-
-       return 0;
-
-}
-EXPORT_SYMBOL(rockchip_wifi_init_module);
-
-void rockchip_wifi_exit_module(void)
-{
-       int timeout;
-       /*
-       
-       lbs_deb_enter(LBS_DEB_SDIO);
-
-       wifi_ps_status = WIFI_PS_AWAKE;
-       
-       sdio_unregister_driver(&if_sdio_driver);
-       
-#ifdef WIFI_GPIO_POWER_CONTROL
-
-    //if (wifi_no_power_gpio == 1)
-       //      return;
-               
-       if (wifi_mmc_host == NULL)
-       {
-               printk("No SDIO host is present.\n");
-               return;
-       }
-*/
-
-       dhd_module_cleanup();
-       
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-       if (wifi_mmc_host == NULL)
-       {
-               printk("No SDIO host is present.\n");
-               return;
-       }
-#endif
-       wifi_turn_off_card();
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-    mmc_detect_change(wifi_mmc_host, 2);
-#else
-    rk29sdk_wifi_set_carddetect(0);
-#endif
-
-       //printk("Waiting for sdio card to be released ... \n");
-       for (timeout = 40; timeout >= 0; timeout--)
-       {
-               msleep(100);
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,25)
-        if (wifi_mmc_host->bus_ops == NULL)
-#else
-        if (wifi_func_removed == 1)
-#endif
-                       break;
-       }
-       if (timeout < 0)
-               printk("Fail to release SDIO card.\n");
-       //else
-               //printk("Success to release SDIO card.\n");
-       printk("%s: timeout = %d (interval = 100 ms)\n", __func__, timeout);
-//#endif
-
-/*     lbs_deb_leave(LBS_DEB_SDIO);*/
-       
-}
-EXPORT_SYMBOL(rockchip_wifi_exit_module);
-
-int mv88w8686_if_sdio_init_module(void)
-{
-       return rockchip_wifi_init_module();
-}
-
-void mv88w8686_if_sdio_exit_module(void)
-{
-       rockchip_wifi_exit_module();
-}
-
-EXPORT_SYMBOL(mv88w8686_if_sdio_init_module);
-EXPORT_SYMBOL(mv88w8686_if_sdio_exit_module);
-
-#ifdef BCMSDH_MODULE
-module_init(dhd_module_init);
-module_exit(dhd_module_cleanup);
-#endif
-/* mobile version
-int if_sdio_init_module2(void)
-{
-    return dhd_module_init();
-}
-
-void if_sdio_exit_module(void)
-{
-   dhd_module_cleanup();
-}
-
-EXPORT_SYMBOL(if_sdio_init_module2);
-EXPORT_SYMBOL(if_sdio_exit_module);
-*/
-/*
- * OS specific functions required to implement DHD driver in OS independent way
- */
-int
-dhd_os_proto_block(dhd_pub_t *pub)
-{
-       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+/*
+ * OS specific functions required to implement DHD driver in OS independent way
+ */
+int
+dhd_os_proto_block(dhd_pub_t *pub)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
 
        if (dhd) {
-               down(&dhd->proto_sem);
+               mutex_lock(&dhd->proto_sem);
                return 1;
        }
+
        return 0;
 }
 
@@ -2620,7 +2666,7 @@ dhd_os_proto_unblock(dhd_pub_t *pub)
        dhd_info_t *dhd = (dhd_info_t *)(pub->info);
 
        if (dhd) {
-               up(&dhd->proto_sem);
+               mutex_unlock(&dhd->proto_sem);
                return 1;
        }
 
@@ -2647,14 +2693,17 @@ dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition, bool *pending)
        int timeout = dhd_ioctl_timeout_msec;
 
        /* Convert timeout in millsecond to jiffies */
-       timeout = timeout * HZ / 1000;
+       /* timeout = timeout * HZ / 1000; */
+       timeout = msecs_to_jiffies(timeout);
 
        /* Wait until control frame is available */
        add_wait_queue(&dhd->ioctl_resp_wait, &wait);
        set_current_state(TASK_INTERRUPTIBLE);
-
-       while (!(*condition) && (!signal_pending(current) && timeout))
+       smp_mb();
+       while (!(*condition) && (!signal_pending(current) && timeout)) {
                timeout = schedule_timeout(timeout);
+               smp_mb();
+       }
 
        if (signal_pending(current))
                *pending = TRUE;
@@ -2681,41 +2730,28 @@ void
 dhd_os_wd_timer(void *bus, uint wdtick)
 {
        dhd_pub_t *pub = bus;
-       static uint save_dhd_watchdog_ms = 0;
        dhd_info_t *dhd = (dhd_info_t *)pub->info;
+       unsigned long flags;
+       int del_timer_flag = FALSE;
 
-       /* don't start the wd until fw is loaded */
-       if (pub->busstate == DHD_BUS_DOWN)
-               return;
-
-       /* Totally stop the timer */
-       if (!wdtick && dhd->wd_timer_valid == TRUE) {
-               del_timer(&dhd->timer);
-               dhd->wd_timer_valid = FALSE;
-               save_dhd_watchdog_ms = wdtick;
-               return;
-       }
-
-       if (wdtick) {
-               dhd_watchdog_ms = (uint) wdtick;
-               if (save_dhd_watchdog_ms != dhd_watchdog_ms) {
-
-                       if (dhd->wd_timer_valid == TRUE)
-                               /* Stop timer and restart at new value */
-                               del_timer(&dhd->timer);
+       flags = dhd_os_spin_lock(pub);
 
-                       /* Create timer again when watchdog period is
-                          dynamically changed or in the first instance
-                       */
-                       dhd->timer.expires = jiffies + dhd_watchdog_ms * HZ / 1000;
-                       add_timer(&dhd->timer);
-               } else {
+       /* don't start the wd until fw is loaded */
+       if (pub->busstate != DHD_BUS_DOWN) {
+               if (wdtick) {
+                       dhd_watchdog_ms = (uint)wdtick;
+                       dhd->wd_timer_valid = TRUE;
                        /* Re arm the timer, at last watchdog period */
                        mod_timer(&dhd->timer, jiffies + dhd_watchdog_ms * HZ / 1000);
+               } else if (dhd->wd_timer_valid == TRUE) {
+                       /* Totally stop the timer */
+                       dhd->wd_timer_valid = FALSE;
+                       del_timer_flag = TRUE;
                }
-
-               dhd->wd_timer_valid = TRUE;
-               save_dhd_watchdog_ms = wdtick;
+       }
+       dhd_os_spin_unlock(pub, flags);
+       if (del_timer_flag) {
+               del_timer_sync(&dhd->timer);
        }
 }
 
@@ -2724,7 +2760,6 @@ dhd_os_open_image(char *filename)
 {
        struct file *fp;
 
-
        fp = filp_open(filename, O_RDONLY, 0);
        /*
         * 2.6.11 (FC4) supports filp_open() but later revs don't?
@@ -2744,7 +2779,6 @@ dhd_os_get_image_block(char *buf, int len, void *image)
        struct file *fp = (struct file *)image;
        int rdlen;
 
-
        if (!image)
                return 0;
 
@@ -2771,9 +2805,9 @@ dhd_os_sdlock(dhd_pub_t *pub)
        dhd = (dhd_info_t *)(pub->info);
 
        if (dhd->threads_only)
-               down(&dhd->sdsem);
+               mutex_lock(&dhd->sdsem);
        else
-       spin_lock_bh(&dhd->sdlock);
+               spin_lock_bh(&dhd->sdlock);
 }
 
 void
@@ -2784,9 +2818,9 @@ dhd_os_sdunlock(dhd_pub_t *pub)
        dhd = (dhd_info_t *)(pub->info);
 
        if (dhd->threads_only)
-               up(&dhd->sdsem);
+               mutex_unlock(&dhd->sdsem);
        else
-       spin_unlock_bh(&dhd->sdlock);
+               spin_unlock_bh(&dhd->sdlock);
 }
 
 void
@@ -2830,7 +2864,7 @@ dhd_os_sdtxunlock(dhd_pub_t *pub)
 #ifdef DHD_USE_STATIC_BUF
 void * dhd_os_prealloc(int section, unsigned long size)
 {
-#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319)
+#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
        void *alloc_ptr = NULL;
        if (wifi_control_data && wifi_control_data->mem_prealloc)
        {
@@ -2847,7 +2881,7 @@ void * dhd_os_prealloc(int section, unsigned long size)
        return 0;
 #else
 return MALLOC(0, size);
-#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC_BCM4319) */
+#endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
 }
 #endif /* DHD_USE_STATIC_BUF */
 #if defined(CONFIG_WIRELESS_EXT)
@@ -2880,12 +2914,19 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
 
 #if defined(CONFIG_WIRELESS_EXT)
        ASSERT(dhd->iflist[*ifidx] != NULL);
+
+       if (ntoh32(event->event_type) == WLC_E_IF) {
+               DHD_INFO(("<0> interface:%d OP:%d don't pass to wext,"
+                       "net_device might not be created yet\n",
+                               *ifidx, ntoh32(event->event_type)));
+               return bcmerror;
+       }
+
        ASSERT(dhd->iflist[*ifidx]->net != NULL);
 
        if (dhd->iflist[*ifidx]->net)
                wl_iw_event(dhd->iflist[*ifidx]->net, event, *data);
-#endif /* defined(CONFIG_WIRELESS_EXT)  */
-
+#endif /* defined(CONFIG_WIRELESS_EXT) */
 
        return (bcmerror);
 }
@@ -2902,7 +2943,7 @@ dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data)
 
 void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar)
 {
-#if 1 && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
        struct dhd_info *dhdinfo =  dhd->info;
        dhd_os_sdunlock(dhd);
        wait_event_interruptible_timeout(dhdinfo->ctrl_wait, (*lockvar == FALSE), HZ * 2);
@@ -2913,32 +2954,90 @@ void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar)
 
 void dhd_wait_event_wakeup(dhd_pub_t *dhd)
 {
-#if 1 && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
        struct dhd_info *dhdinfo =  dhd->info;
        if (waitqueue_active(&dhdinfo->ctrl_wait))
                wake_up_interruptible(&dhdinfo->ctrl_wait);
 #endif
        return;
 }
+
 int
 dhd_dev_reset(struct net_device *dev, uint8 flag)
 {
+       int ret;
+
        dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
 
-       /* Turning off watchdog */
-       if (flag)
-               dhd_os_wd_timer(&dhd->pub, 0);
+       ret = dhd_bus_devreset(&dhd->pub, flag);
+       if (ret) {
+               DHD_ERROR(("%s: dhd_bus_devreset: %d\n", __FUNCTION__, ret));
+               return ret;
+       }
+       DHD_ERROR(("%s: WLAN %s DONE\n", __FUNCTION__, flag ? "OFF" : "ON"));
 
-       dhd_bus_devreset(&dhd->pub, flag);
+       return ret;
+}
 
-       /* Turning on watchdog back */
-       if (!flag)
-               dhd_os_wd_timer(&dhd->pub, dhd_watchdog_ms);
-       DHD_ERROR(("%s:  WLAN OFF DONE\n", __FUNCTION__));
+int net_os_set_suspend_disable(struct net_device *dev, int val)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
 
-       return 1;
+       if (dhd) {
+               ret = dhd->pub.suspend_disable_flag;
+               dhd->pub.suspend_disable_flag = val;
+       }
+       return ret;
 }
 
+int net_os_set_suspend(struct net_device *dev, int val)
+{
+       int ret = 0;
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       if (dhd) {
+               dhd_os_proto_block(&dhd->pub);
+               ret = dhd_set_suspend(val, &dhd->pub);
+               dhd_os_proto_unblock(&dhd->pub);
+       }
+#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
+       return ret;
+}
+
+int net_os_set_dtim_skip(struct net_device *dev, int val)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       if (dhd)
+               dhd->pub.dtim_skip = val;
+
+       return 0;
+}
+
+int net_os_set_packet_filter(struct net_device *dev, int val)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
+
+       /* Packet filtering is set only if we still in early-suspend and
+        * we need either to turn it ON or turn it OFF
+        * We can always turn it OFF in case of early-suspend, but we turn it
+        * back ON only if suspend_disable_flag was not set
+       */
+       if (dhd && dhd->pub.up) {
+               dhd_os_proto_block(&dhd->pub);
+               if (dhd->pub.in_suspend) {
+                       if (!val || (val && !dhd->pub.suspend_disable_flag))
+                               dhd_set_packet_filter(val, &dhd->pub);
+               }
+               dhd_os_proto_unblock(&dhd->pub);
+       }
+       return ret;
+}
+
+
 void
 dhd_dev_init_ioctl(struct net_device *dev)
 {
@@ -2947,6 +3046,98 @@ dhd_dev_init_ioctl(struct net_device *dev)
        dhd_preinit_ioctls(&dhd->pub);
 }
 
+#ifdef PNO_SUPPORT
+/* Linux wrapper to call common dhd_pno_clean */
+int
+dhd_dev_pno_reset(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       return (dhd_pno_clean(&dhd->pub));
+}
+
+
+/* Linux wrapper to call common dhd_pno_enable */
+int
+dhd_dev_pno_enable(struct net_device *dev,  int pfn_enabled)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       return (dhd_pno_enable(&dhd->pub, pfn_enabled));
+}
+
+
+/* Linux wrapper to call common dhd_pno_set */
+int
+dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nssid, ushort  scan_fr)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       return (dhd_pno_set(&dhd->pub, ssids_local, nssid, scan_fr));
+}
+
+/* Linux wrapper to get  pno status */
+int
+dhd_dev_get_pno_status(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       return (dhd_pno_get_status(&dhd->pub));
+}
+
+#endif /* PNO_SUPPORT */
+
+int net_os_send_hang_message(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
+
+       if (dhd) {
+               if (!dhd->hang_was_sent) {
+                       dhd->hang_was_sent = 1;
+                       ret = wl_iw_send_priv_event(dev, "HANG");
+               }
+       }
+       return ret;
+}
+
+void dhd_bus_country_set(struct net_device *dev, char *country_code)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       if (dhd && dhd->pub.up)
+               strncpy(dhd->pub.country_code, country_code, WLC_CNTRY_BUF_SZ);
+}
+
+char *dhd_bus_country_get(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+
+       if (dhd && (dhd->pub.country_code[0] != 0))
+               return dhd->pub.country_code;
+       return NULL;
+}
+
+void dhd_os_start_lock(dhd_pub_t *pub)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+
+       if (dhd)
+               mutex_lock(&dhd->wl_start_lock);
+#endif
+}
+
+void dhd_os_start_unlock(dhd_pub_t *pub)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+
+       if (dhd)
+               mutex_unlock(&dhd->wl_start_lock);
+#endif
+}
+
 static int
 dhd_get_pend_8021x_cnt(dhd_info_t *dhd)
 {
@@ -3011,3 +3202,139 @@ exit:
        return ret;
 }
 #endif /* DHD_DEBUG */
+
+int dhd_os_wake_lock_timeout(dhd_pub_t *pub)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+       unsigned long flags;
+       int ret = 0;
+
+       if (dhd) {
+               spin_lock_irqsave(&dhd->wl_lock, flags);
+               ret = dhd->wl_packet;
+#ifdef CONFIG_HAS_WAKELOCK
+               if (dhd->wl_packet)
+                       wake_lock_timeout(&dhd->wl_rxwake, HZ);
+#endif
+               dhd->wl_packet = 0;
+               spin_unlock_irqrestore(&dhd->wl_lock, flags);
+       }
+       /* printk("%s: %d\n", __FUNCTION__, ret); */
+       return ret;
+}
+
+int net_os_wake_lock_timeout(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
+
+       if (dhd)
+               ret = dhd_os_wake_lock_timeout(&dhd->pub);
+       return ret;
+}
+
+int dhd_os_wake_lock_timeout_enable(dhd_pub_t *pub)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+       unsigned long flags;
+
+       if (dhd) {
+               spin_lock_irqsave(&dhd->wl_lock, flags);
+               dhd->wl_packet = 1;
+               spin_unlock_irqrestore(&dhd->wl_lock, flags);
+       }
+       /* printk("%s\n",__func__); */
+       return 0;
+}
+
+int net_os_wake_lock_timeout_enable(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
+
+       if (dhd)
+               ret = dhd_os_wake_lock_timeout_enable(&dhd->pub);
+       return ret;
+}
+
+int dhd_os_wake_lock(dhd_pub_t *pub)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+       unsigned long flags;
+       int ret = 0;
+
+       if (dhd) {
+               spin_lock_irqsave(&dhd->wl_lock, flags);
+#ifdef CONFIG_HAS_WAKELOCK
+               if (!dhd->wl_count)
+                       wake_lock(&dhd->wl_wifi);
+#endif
+               dhd->wl_count++;
+               ret = dhd->wl_count;
+               spin_unlock_irqrestore(&dhd->wl_lock, flags);
+       }
+       /* printk("%s: %d\n", __FUNCTION__, ret); */
+       return ret;
+}
+
+int net_os_wake_lock(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
+
+       if (dhd)
+               ret = dhd_os_wake_lock(&dhd->pub);
+       return ret;
+}
+
+int dhd_os_wake_unlock(dhd_pub_t *pub)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+       unsigned long flags;
+       int ret = 0;
+
+       dhd_os_wake_lock_timeout(pub);
+       if (dhd) {
+               spin_lock_irqsave(&dhd->wl_lock, flags);
+               if (dhd->wl_count) {
+                       dhd->wl_count--;
+#ifdef CONFIG_HAS_WAKELOCK
+                       if (!dhd->wl_count)
+                               wake_unlock(&dhd->wl_wifi);
+#endif
+                       ret = dhd->wl_count;
+               }
+               spin_unlock_irqrestore(&dhd->wl_lock, flags);
+       }
+       /* printk("%s: %d\n", __FUNCTION__, ret); */
+       return ret;
+}
+
+int net_os_wake_unlock(struct net_device *dev)
+{
+       dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
+       int ret = 0;
+
+       if (dhd)
+               ret = dhd_os_wake_unlock(&dhd->pub);
+       return ret;
+}
+
+unsigned long dhd_os_spin_lock(dhd_pub_t *pub)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+       unsigned long flags = 0;
+
+       if (dhd)
+               spin_lock_irqsave(&dhd->dhd_lock, flags);
+
+       return flags;
+}
+
+void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags)
+{
+       dhd_info_t *dhd = (dhd_info_t *)(pub->info);
+
+       if (dhd)
+               spin_unlock_irqrestore(&dhd->dhd_lock, flags);
+}
index 382785a1ff6b47baf31f1febd2ac54b71bdaa57a..7ef6929a5bf728a693c9b761220d4a760d4c2498 100644 (file)
@@ -34,7 +34,7 @@
 #include <wlioctl.h>
 
 #ifndef IOCTL_RESP_TIMEOUT
-#define IOCTL_RESP_TIMEOUT  2000 /* In milli second */
+#define IOCTL_RESP_TIMEOUT  3000 /* In milli second */
 #endif
 
 #ifndef IOCTL_CHIP_ACTIVE_TIMEOUT
index cac624a918b672741a09d5bbe4b9b515c0051d4a..78dff1c489b8a8d31b82c122b14ca9c26f141a02 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: dhd_sdio.c,v 1.157.2.27.2.33.2.126 2010/06/15 23:38:39 Exp $
+ * $Id: dhd_sdio.c,v 1.157.2.27.2.33.2.129.4.1 2010/09/02 23:13:16 Exp $
  */
 
 #include <typedefs.h>
 #include <bcmutils.h>
 #include <bcmendian.h>
 #include <bcmdevs.h>
-
 #include <siutils.h>
 #include <hndpmu.h>
 #include <hndsoc.h>
-#ifdef DHD_DEBUG
-#include <hndrte_armtrap.h>
-#include <hndrte_cons.h>
-#endif /* DHD_DEBUG */
 #include <sbchipc.h>
 #include <sbhnddma.h>
-
 #include <sdio.h>
 #include <sbsdio.h>
 #include <sbsdpcmdev.h>
 #include <dhdioctl.h>
 #include <sdiovar.h>
 
-#ifndef DHDSDIO_MEM_DUMP_FNAME
-#define DHDSDIO_MEM_DUMP_FNAME         "mem_dump"
-#endif
+#ifdef DHD_DEBUG
+#include <hndrte_cons.h>
+#endif /* DHD_DEBUG */
+#ifdef DHD_DEBUG_TRAP
+#include <hndrte_armtrap.h>
+#endif /* DHD_DEBUG_TRAP */
 
 #define QLEN           256     /* bulk rx and tx queue lengths */
 #define FCHI           (QLEN - 10)
 /* Bump up limit on waiting for HT to account for first startup;
  * if the image is doing a CRC calculation before programming the PMU
  * for HT availability, it could take a couple hundred ms more, so
- * max out at a half second (500000us).
+ * max out at a 1 second (1000000us).
  */
-#if (PMU_MAX_TRANSITION_DLY <= 500000)
+#if (PMU_MAX_TRANSITION_DLY < 1000000)
 #undef PMU_MAX_TRANSITION_DLY
-#define PMU_MAX_TRANSITION_DLY 500000
+#define PMU_MAX_TRANSITION_DLY 1000000
 #endif
 
 /* Value for ChipClockCSR during initial setup */
 DHD_SPINWAIT_SLEEP_INIT(sdioh_spinwait_sleep);
 extern int dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len);
 
+extern void bcmsdh_set_irq(int flag);
+
 #ifdef DHD_DEBUG
 /* Device console log buffer state */
 typedef struct dhd_console {
@@ -427,10 +426,10 @@ static void dhdsdio_testrcv(dhd_bus_t *bus, void *pkt, uint seq);
 static void dhdsdio_sdtest_set(dhd_bus_t *bus, bool start);
 #endif
 
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
 static int dhdsdio_checkdied(dhd_bus_t *bus, uint8 *data, uint size);
 static int dhdsdio_mem_dump(dhd_bus_t *bus);
-#endif /* DHD_DEBUG  */
+#endif /* DHD_DEBUG_TRAP */
 static int dhdsdio_download_state(dhd_bus_t *bus, bool enter);
 
 static void dhdsdio_release(dhd_bus_t *bus, osl_t *osh);
@@ -441,7 +440,7 @@ static bool dhdsdio_probe_attach(dhd_bus_t *bus, osl_t *osh, void *sdh,
                                  void * regsva, uint16  devid);
 static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh);
 static bool dhdsdio_probe_init(dhd_bus_t *bus, osl_t *osh, void *sdh);
-static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh);
+static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, int reset_flag);
 
 static uint process_nvram_vars(char *varbuf, uint len);
 
@@ -551,7 +550,6 @@ dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok)
                        bcmsdh_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err);
                        DHD_INFO(("CLKCTL: set PENDING\n"));
                        bus->clkstate = CLK_PENDING;
-
                        return BCME_OK;
                } else if (bus->clkstate == CLK_PENDING) {
                        /* Cancel CA-only interrupt filter */
@@ -722,7 +720,7 @@ 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 ret;
        }
 
        switch (target) {
@@ -747,9 +745,8 @@ dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok)
                else
                        DHD_ERROR(("dhdsdio_clkctl: request for %d -> %d\n",
                                   bus->clkstate, target));
-               if (ret == BCME_OK) {
+               if (ret == BCME_OK)
                        dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms);
-               }
                break;
 
        case CLK_NONE:
@@ -1303,7 +1300,6 @@ dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen)
                        bus->ctrl_frame_stat = FALSE;
                        ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC,
                                                  frame, len, NULL, NULL, NULL);
-
                        ASSERT(ret != BCME_PENDING);
 
                        if (ret < 0) {
@@ -1377,21 +1373,21 @@ dhd_bus_rxctl(struct dhd_bus *bus, uchar *msg, uint msglen)
                         __FUNCTION__, rxlen, msglen));
        } else if (timeleft == 0) {
                DHD_ERROR(("%s: resumed on timeout\n", __FUNCTION__));
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
                dhd_os_sdlock(bus->dhd);
                dhdsdio_checkdied(bus, NULL, 0);
                dhd_os_sdunlock(bus->dhd);
-#endif /* DHD_DEBUG */
+#endif /* DHD_DEBUG_TRAP */
        } else if (pending == TRUE) {
                DHD_CTL(("%s: cancelled\n", __FUNCTION__));
                return -ERESTARTSYS;
        } else {
                DHD_CTL(("%s: resumed for unknown reason?\n", __FUNCTION__));
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
                dhd_os_sdlock(bus->dhd);
                dhdsdio_checkdied(bus, NULL, 0);
                dhd_os_sdunlock(bus->dhd);
-#endif /* DHD_DEBUG */
+#endif /* DHD_DEBUG_TRAP */
        }
 
        if (rxlen)
@@ -1411,7 +1407,7 @@ enum {
        IOV_SDCIS,
        IOV_MEMBYTES,
        IOV_MEMSIZE,
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
        IOV_CHECKDIED,
 #endif
        IOV_DOWNLOAD,
@@ -1464,10 +1460,10 @@ const bcm_iovar_t dhdsdio_iovars[] = {
        {"rxbound",     IOV_RXBOUND,    0,      IOVT_UINT32,    0 },
        {"txminmax", IOV_TXMINMAX,      0,      IOVT_UINT32,    0 },
        {"cpu",         IOV_CPU,        0,      IOVT_BOOL,      0 },
-#ifdef DHD_DEBUG
-       {"checkdied",   IOV_CHECKDIED,  0,      IOVT_BUFFER,    0 },
-#endif /* DHD_DEBUG  */
 #endif /* DHD_DEBUG */
+#ifdef DHD_DEBUG_TRAP
+       {"checkdied",   IOV_CHECKDIED,  0,      IOVT_BUFFER,    0 },
+#endif /* DHD_DEBUG_TRAP  */
 #ifdef SDTEST
        {"extloop",     IOV_EXTLOOP,    0,      IOVT_BOOL,      0 },
        {"pktgen",      IOV_PKTGEN,     0,      IOVT_BUFFER,    sizeof(dhd_pktgen_t) },
@@ -1696,7 +1692,7 @@ xfer_done:
        return bcmerror;
 }
 
-#ifdef DHD_DEBUG
+#ifdef DHD_DEBUG_TRAP
 static int
 dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh)
 {
@@ -1849,12 +1845,10 @@ dhdsdio_checkdied(dhd_bus_t *bus, uint8 *data, uint size)
                DHD_ERROR(("%s: %s\n", __FUNCTION__, strbuf.origbuf));
        }
 
-#ifdef DHD_DEBUG
        if (sdpcm_shared.flags & SDPCM_SHARED_TRAP) {
-               /* Mem dump to a file on device */
-               dhdsdio_mem_dump(bus);
+                       /* Mem dump to a file on device */
+                       dhdsdio_mem_dump(bus);
        }
-#endif /* DHD_DEBUG */
 
 done:
        if (mbuffer)
@@ -1905,17 +1899,22 @@ dhdsdio_mem_dump(dhd_bus_t *bus)
        }
        printf("Done\n");
 
+#ifdef DHD_DEBUG
        /* free buf before return !!! */
        if (write_to_file(bus->dhd, buf, bus->ramsize))
        {
                printf("%s: Error writing to files\n", __FUNCTION__);
                return -1;
        }
-
        /* buf free handled in write_to_file, not here */
+#else
+       MFREE(bus->dhd->osh, buf, size);
+#endif
        return 0;
 }
+#endif /* DHD_DEBUG_TRAP */
 
+#ifdef DHD_DEBUG
 #define CONSOLE_LINE_MAX       192
 
 static int
@@ -2726,6 +2725,9 @@ dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
 
        BUS_WAKE(bus);
 
+       /* Change our idea of bus state */
+       bus->dhd->busstate = DHD_BUS_DOWN;
+
        /* Enable clock for device interrupts */
        dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
 
@@ -2734,9 +2736,6 @@ dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
        local_hostintmask = bus->hostintmask;
        bus->hostintmask = 0;
 
-       /* Change our idea of bus state */
-       bus->dhd->busstate = DHD_BUS_DOWN;
-
        /* Force clocks on backplane to be sure F2 interrupt propagates */
        saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err);
        if (!err) {
@@ -2789,23 +2788,24 @@ dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
        dhd_timeout_t tmo;
        uint retries = 0;
        uint8 ready, enable;
-       int err, ret = 0;
+       int err, ret = BCME_ERROR;
        uint8 saveclk;
 
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
        ASSERT(bus->dhd);
        if (!bus->dhd)
-               return 0;
+               return BCME_OK;
 
        if (enforce_mutex)
                dhd_os_sdlock(bus->dhd);
 
        /* Make sure backplane clock is on, needed to generate F2 interrupt */
-       dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
-       if (bus->clkstate != CLK_AVAIL)
+       err = dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
+       if ((err != BCME_OK) || (bus->clkstate != CLK_AVAIL)) {
+               DHD_ERROR(("%s: Failed to set backplane clock: err %d\n", __FUNCTION__, err));
                goto exit;
-
+       }
 
        /* Force clocks on backplane to be sure F2 interrupt propagates */
        saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err);
@@ -2880,6 +2880,7 @@ dhd_bus_init(dhd_pub_t *dhdp, bool enforce_mutex)
        if (dhdp->busstate != DHD_BUS_DATA)
                dhdsdio_clkctl(bus, CLK_NONE, FALSE);
 
+       ret = BCME_OK;
 exit:
        if (enforce_mutex)
                dhd_os_sdunlock(bus->dhd);
@@ -4233,6 +4234,9 @@ clkwait:
                DHD_INTR(("%s: enable SDIO interrupts, rxdone %d framecnt %d\n",
                          __FUNCTION__, rxdone, framecnt));
                bus->intdis = FALSE;
+#if defined(OOB_INTR_ONLY)
+               bcmsdh_oob_intr_set(1);
+#endif /* (OOB_INTR_ONLY) */
                bcmsdh_intr_enable(sdh);
        }
 
@@ -4367,13 +4371,14 @@ dhdsdio_isr(void *arg)
 
 #if defined(SDIO_ISR_THREAD)
        DHD_TRACE(("Calling dhdsdio_dpc() from %s\n", __FUNCTION__));
+       dhd_os_wake_lock(bus->dhd);
        while (dhdsdio_dpc(bus));
+       dhd_os_wake_unlock(bus->dhd);
 #else
        bus->dpc_sched = TRUE;
        dhd_sched_dpc(bus->dhd);
 #endif 
 
-
 }
 
 #ifdef SDTEST
@@ -4634,8 +4639,6 @@ dhd_bus_watchdog(dhd_pub_t *dhdp)
        if (bus->sleeping)
                return FALSE;
 
-       dhd_os_sdlock(bus->dhd);
-
        /* Poll period: check device if appropriate. */
        if (bus->poll && (++bus->polltick >= bus->pollrate)) {
                uint32 intstatus = 0;
@@ -4700,15 +4703,11 @@ dhd_bus_watchdog(dhd_pub_t *dhdp)
                        bus->idlecount = 0;
                        if (bus->activity) {
                                bus->activity = FALSE;
-                               dhd_os_wd_timer(bus->dhd,dhd_watchdog_ms);
-                       } else {
                                dhdsdio_clkctl(bus, CLK_NONE, FALSE);
                        }
                }
        }
 
-       dhd_os_sdunlock(bus->dhd);
-
        return bus->ipend;
 }
 
@@ -4960,12 +4959,15 @@ dhdsdio_probe(uint16 venid, uint16 devid, uint16 bus_no, uint16 slot,
 
        /* if firmware path present try to download and bring up bus */
        if ((ret = dhd_bus_start(bus->dhd)) != 0) {
+#if 1
                DHD_ERROR(("%s: failed\n", __FUNCTION__));
                goto fail;
+#else
                if (ret == BCME_NOTUP)  {
                        DHD_ERROR(("%s: dongle is not responding\n", __FUNCTION__));
                        goto fail;
                }
+#endif
        }
        /* Ok, have the per-port tell the stack we're open for business */
        if (dhd_net_attach(bus->dhd, 0) != 0) {
@@ -5266,7 +5268,6 @@ dhd_bus_download_firmware(struct dhd_bus *bus, osl_t *osh,
 
        ret = dhdsdio_download_firmware(bus, osh, bus->sdh);
 
-
        return ret;
 }
 
@@ -5276,12 +5277,13 @@ dhdsdio_download_firmware(struct dhd_bus *bus, osl_t *osh, void *sdh)
        bool ret;
 
        /* Download the firmware */
+       dhd_os_wake_lock(bus->dhd);
        dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
 
        ret = _dhdsdio_download_firmware(bus) == 0;
 
        dhdsdio_clkctl(bus, CLK_SDONLY, FALSE);
-
+       dhd_os_wake_unlock(bus->dhd);
        return ret;
 }
 
@@ -5301,7 +5303,7 @@ dhdsdio_release(dhd_bus_t *bus, osl_t *osh)
 
                if (bus->dhd) {
 
-                       dhdsdio_release_dongle(bus, osh);
+                       dhdsdio_release_dongle(bus, osh, TRUE);
 
                        dhd_detach(bus->dhd);
                        bus->dhd = NULL;
@@ -5345,11 +5347,11 @@ dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh)
 
 
 static void
-dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh)
+dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, int reset_flag)
 {
        DHD_TRACE(("%s: Enter\n", __FUNCTION__));
 
-       if (bus->dhd && bus->dhd->dongle_reset)
+       if ((bus->dhd && bus->dhd->dongle_reset) && reset_flag)
                return;
 
        if (bus->sih) {
@@ -5799,24 +5801,25 @@ dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag)
 
        if (flag == TRUE) {
                if (!bus->dhd->dongle_reset) {
+                       dhd_os_sdlock(dhdp);
+                       /* Turning off watchdog */
+                       dhd_os_wd_timer(dhdp, 0);
 #if !defined(IGNORE_ETH0_DOWN)
                        /* Force flow control as protection when stop come before ifconfig_down */
                        dhd_txflowcontrol(bus->dhd, 0, ON);
 #endif /* !defined(IGNORE_ETH0_DOWN) */
-                       /* save country settinng if was pre-setup with priv ioctl */
-                       dhd_os_proto_block(dhdp);
-                       dhdcdc_query_ioctl(bus->dhd, 0, WLC_GET_COUNTRY,
-                               bus->dhd->country_code, sizeof(bus->dhd->country_code));
-                       dhd_os_proto_unblock(dhdp);
                        /* Expect app to have torn down any connection before calling */
                        /* Stop the bus, disable F2 */
                        dhd_bus_stop(bus, FALSE);
-
+#if defined(OOB_INTR_ONLY)
+                       bcmsdh_set_irq(FALSE);
+#endif /* defined(OOB_INTR_ONLY) */
                        /* Clean tx/rx buffer pointers, detach from the dongle */
-                       dhdsdio_release_dongle(bus, bus->dhd->osh);
+                       dhdsdio_release_dongle(bus, bus->dhd->osh, TRUE);
 
                        bus->dhd->dongle_reset = TRUE;
                        bus->dhd->up = FALSE;
+                       dhd_os_sdunlock(dhdp);
 
                        DHD_TRACE(("%s:  WLAN OFF DONE\n", __FUNCTION__));
                        /* App can now remove power from device */
@@ -5829,6 +5832,8 @@ dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag)
 
                if (bus->dhd->dongle_reset) {
                        /* Turn on WLAN */
+                       dhd_os_sdlock(dhdp);
+
                        /* Reset SD client */
                        bcmsdh_reset(bus->sdh);
 
@@ -5841,25 +5846,32 @@ dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag)
                                        dhdsdio_download_firmware(bus, bus->dhd->osh, bus->sdh)) {
 
                                        /* Re-init bus, enable F2 transfer */
-                                       dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE);
-
+                                       bcmerror = dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE);
+                                       if (bcmerror == BCME_OK) {
 #if defined(OOB_INTR_ONLY)
-                                       dhd_enable_oob_intr(bus, TRUE);
+                                               bcmsdh_set_irq(TRUE);
+                                               dhd_enable_oob_intr(bus, TRUE);
 #endif /* defined(OOB_INTR_ONLY) */
-
-                                       bus->dhd->dongle_reset = FALSE;
-                                       bus->dhd->up = TRUE;
-
+                                               bus->dhd->dongle_reset = FALSE;
+                                               bus->dhd->up = TRUE;
 #if !defined(IGNORE_ETH0_DOWN)
-                                       /* Restore flow control  */
-                                       dhd_txflowcontrol(bus->dhd, 0, OFF);
-#endif 
+                                               /* Restore flow control  */
+                                               dhd_txflowcontrol(bus->dhd, 0, OFF);
+#endif
+                                               /* Turning on watchdog back */
+                                               dhd_os_wd_timer(dhdp, dhd_watchdog_ms);
 
-                                       DHD_TRACE(("%s: WLAN ON DONE\n", __FUNCTION__));
+                                               DHD_TRACE(("%s: WLAN ON DONE\n", __FUNCTION__));
+                                       } else {
+                                               dhd_bus_stop(bus, FALSE);
+                                               dhdsdio_release_dongle(bus, bus->dhd->osh, FALSE);
+                                       }
                                } else
                                        bcmerror = BCME_SDIO_ERROR;
                        } else
                                bcmerror = BCME_SDIO_ERROR;
+
+                       dhd_os_sdunlock(dhdp);
                } else {
                        bcmerror = BCME_NOTDOWN;
                        DHD_ERROR(("%s: Set DEVRESET=FALSE invoked when device is on\n",
diff --git a/drivers/net/wireless/bcm4319/firmware/nvram_4319_201008.txt b/drivers/net/wireless/bcm4319/firmware/nvram_4319_201008.txt
deleted file mode 100644 (file)
index 452ea8f..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-# bcm94319wlusbn4l board\r
-# $Copyright (C) 2008 Broadcom Corporation$\r
-# $Id: bcm94319lcsdn4l.txt,v 1.18 2009/11/11 17:44:06 jayaramn Exp $\r
-\r
-sromrev=3\r
-vendid=0x14e4\r
-devid=0x4338\r
-\r
-boardtype=0x507\r
-boardrev=0x1402\r
-boardflags=0x02000200\r
-\r
-# On board crystal frequency in KHz\r
-xtalfreq=30000\r
-\r
-aa2g=1\r
-aa5g=0\r
-ag0=3\r
-\r
-ccode=ww\r
-regrev=5\r
-opo=0\r
-pa0b0=0x15E0\r
-pa0b1=0xFAC6\r
-pa0b2=0xFEC3\r
-pa0itssit=62\r
-pa0maxpwr=74\r
-\r
-rssismf2g=0xa \r
-rssismc2g=0xb \r
-rssisav2g=0x3 \r
-bxa2g=0\r
-tri2g=0x6B\r
-cckdigfilttype=3\r
-rxpo2g=2\r
-\r
-cckpo=0\r
-ofdmpo=0x44444444\r
-mcs2gpo0=0x6666\r
-mcs2gpo1=0x6666\r
-mcs2gpo2=0x0000\r
-mcs2gpo3=0x0000\r
-mcs2gpo4=0x6666\r
-mcs2gpo5=0x6666\r
-boardnum=1\r
-macaddr=00:90:4c:14:43:19\r
-\r
-#for mfgc\r
-otpimagesize=182\r
index e3c6876f86fab5b8ecd52480e141aee520cba3e5..f4e99461971b012cd9a56e1b09a0f8fc81532d10 100644 (file)
@@ -29,7 +29,6 @@
 
 #define STATIC static
 
-
 #define        SI_BUS                  0       
 #define        PCI_BUS                 1       
 #define        PCMCIA_BUS              2       
index 6ec5874b6187310d13894cc3dc6d276d12bbe8fd..4e6d1b5bd94f5a93479f4cdad936062758a800a4 100644 (file)
@@ -28,7 +28,7 @@
 #define __BCMSDH_SDMMC_H__
 
 #define sd_err(x)
-#define sd_trace(x) 
+#define sd_trace(x)
 #define sd_info(x)
 #define sd_debug(x)
 #define sd_data(x)
diff --git a/drivers/net/wireless/bcm4319/include/bcmspibrcm.h b/drivers/net/wireless/bcm4319/include/bcmspibrcm.h
new file mode 100644 (file)
index 0000000..9dce878
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * SD-SPI Protocol Conversion - BCMSDH->gSPI Translation Layer
+ *
+ * Copyright (C) 2010, Broadcom Corporation
+ * All Rights Reserved.
+ * 
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of Broadcom Corporation.
+ *
+ * $Id: bcmspibrcm.h,v 1.4.4.1.4.3.6.1 2008/09/27 17:03:25 Exp $
+ */
+
+/* global msglevel for debug messages - bitvals come from sdiovar.h */
+
+#define sd_err(x)
+#define sd_trace(x)
+#define sd_info(x)
+#define sd_debug(x)
+#define sd_data(x)
+#define sd_ctrl(x)
+
+#define sd_log(x)
+
+#define SDIOH_ASSERT(exp) \
+       do { if (!(exp)) \
+               printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
+       } while (0)
+
+#define BLOCK_SIZE_F1          64
+#define BLOCK_SIZE_F2          2048
+#define BLOCK_SIZE_F3          2048
+
+/* internal return code */
+#define SUCCESS        0
+#undef ERROR
+#define ERROR  1
+#define ERROR_UF       2
+#define ERROR_OF       3
+
+/* private bus modes */
+#define SDIOH_MODE_SPI         0
+
+#define USE_BLOCKMODE          0x2     /* Block mode can be single block or multi */
+#define USE_MULTIBLOCK         0x4
+
+struct sdioh_info {
+       uint            cfg_bar;                /* pci cfg address for bar */
+       uint32          caps;                   /* cached value of capabilities reg */
+       void            *bar0;                  /* BAR0 for PCI Device */
+       osl_t           *osh;                   /* osh handler */
+       void            *controller;    /* Pointer to SPI Controller's private data struct */
+
+       uint            lockcount;              /* nest count of spi_lock() calls */
+       bool            client_intr_enabled;    /* interrupt connnected flag */
+       bool            intr_handler_valid;     /* client driver interrupt handler valid */
+       sdioh_cb_fn_t   intr_handler;           /* registered interrupt handler */
+       void            *intr_handler_arg;      /* argument to call interrupt handler */
+       bool            initialized;            /* card initialized */
+       uint32          target_dev;             /* Target device ID */
+       uint32          intmask;                /* Current active interrupts */
+       void            *sdos_info;             /* Pointer to per-OS private data */
+
+       uint32          controller_type;        /* Host controller type */
+       uint8           version;                /* Host Controller Spec Compliance Version */
+       uint            irq;                    /* Client irq */
+       uint32          intrcount;              /* Client interrupts */
+       uint32          local_intrcount;        /* Controller interrupts */
+       bool            host_init_done;         /* Controller initted */
+       bool            card_init_done;         /* Client SDIO interface initted */
+       bool            polled_mode;            /* polling for command completion */
+
+       bool            sd_use_dma;             /* DMA on CMD53 */
+       bool            sd_blockmode;           /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
+                                               /*  Must be on for sd_multiblock to be effective */
+       bool            use_client_ints;        /* If this is false, make sure to restore */
+                                               /*  polling hack in wl_linux.c:wl_timer() */
+       int             adapter_slot;           /* Maybe dealing with multiple slots/controllers */
+       int             sd_mode;                /* SD1/SD4/SPI */
+       int             client_block_size[SPI_MAX_IOFUNCS];             /* Blocksize */
+       uint32          data_xfer_count;        /* Current transfer */
+       uint16          card_rca;               /* Current Address */
+       uint8           num_funcs;              /* Supported funcs on client */
+       uint32          card_dstatus;           /* 32bit device status */
+       uint32          com_cis_ptr;
+       uint32          func_cis_ptr[SPI_MAX_IOFUNCS];
+       void            *dma_buf;
+       ulong           dma_phys;
+       int             r_cnt;                  /* rx count */
+       int             t_cnt;                  /* tx_count */
+       uint32          wordlen;                        /* host processor 16/32bits */
+       uint32          prev_fun;
+       uint32          chip;
+       uint32          chiprev;
+       bool            resp_delay_all;
+       bool            dwordmode;
+
+       struct spierrstats_t spierrstats;
+};
+
+/************************************************************
+ * Internal interfaces: per-port references into bcmspibrcm.c
+ */
+
+/* Global message bits */
+extern uint sd_msglevel;
+
+/**************************************************************
+ * Internal interfaces: bcmspibrcm.c references to per-port code
+ */
+
+/* Interrupt (de)registration routines */
+extern int spi_register_irq(sdioh_info_t *sd, uint irq);
+extern void spi_free_irq(uint irq, sdioh_info_t *sd);
+
+/* OS-specific interrupt wrappers (atomic interrupt enable/disable) */
+extern void spi_lock(sdioh_info_t *sd);
+extern void spi_unlock(sdioh_info_t *sd);
+
+/* Allocate/init/free per-OS private data */
+extern int spi_osinit(sdioh_info_t *sd);
+extern void spi_osfree(sdioh_info_t *sd);
+
+#define SPI_RW_FLAG_M                  BITFIELD_MASK(1)        /* Bit [31] - R/W Command Bit */
+#define SPI_RW_FLAG_S                  31
+#define SPI_ACCESS_M                   BITFIELD_MASK(1)        /* Bit [30] - Fixed/Incr Access */
+#define SPI_ACCESS_S                   30
+#define SPI_FUNCTION_M                 BITFIELD_MASK(2)        /* Bit [29:28] - Function Number */
+#define SPI_FUNCTION_S                 28
+#define SPI_REG_ADDR_M                 BITFIELD_MASK(17)       /* Bit [27:11] - Address */
+#define SPI_REG_ADDR_S                 11
+#define SPI_LEN_M                      BITFIELD_MASK(11)       /* Bit [10:0] - Packet length */
+#define SPI_LEN_S                      0
index 114c735fb381915b618372c7121b74daef4eb32c..23ee514a7b6b8422fc9c90317533fe5703344ad1 100644 (file)
 
 #define        EPI_MINOR_VERSION       218
 
-#define        EPI_RC_NUMBER           245
+#define        EPI_RC_NUMBER           248
 
-#define        EPI_INCREMENTAL_NUMBER  0
+#define        EPI_INCREMENTAL_NUMBER  18
 
 #define        EPI_BUILD_NUMBER        0
 
-#define        EPI_VERSION             4, 218, 245, 0
+#define        EPI_VERSION             4, 218, 248, 18
 
-#define        EPI_VERSION_NUM         0x04daf500
+#define        EPI_VERSION_NUM         0x04daf812
 
 
-#define        EPI_VERSION_STR         "4.218.245.0"
-#define        EPI_ROUTER_VERSION_STR  "4.219.245.0"
+#define        EPI_VERSION_STR         "4.218.248.18"
+#define        EPI_ROUTER_VERSION_STR  "4.219.248.18"
 
 #endif 
index 6ee5c5872f617e36a810b19e61e72e958846bd20..6ed22658a72ba7e2311cb4ce21a23f70674ba574 100644 (file)
 #include <linux/version.h>
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
 #include <linux/config.h>
-#else
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
-#include <generated/autoconf.h>
-#else
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33))
 #include <linux/autoconf.h>
 #endif
-#endif 
 #include <linux/module.h>
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0))
@@ -70,6 +66,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/netdevice.h>
+#include <linux/semaphore.h>
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
 #undef IP_TOS
 #endif 
@@ -429,22 +426,11 @@ pci_restore_state(struct pci_dev *dev, u32 *buffer)
 #define CHECKSUM_HW    CHECKSUM_PARTIAL
 #endif
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
-#define KILL_PROC(nr, sig) \
-{ \
-struct task_struct *tsk; \
-struct pid *pid;    \
-pid = find_get_pid((pid_t)nr);    \
-tsk = pid_task(pid, PIDTYPE_PID);    \
-if (tsk) send_sig(sig, tsk, 1); \
-}
-#else
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && (LINUX_VERSION_CODE <= \
-       KERNEL_VERSION(2, 6, 30))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
 #define KILL_PROC(pid, sig) \
 { \
        struct task_struct *tsk; \
-       tsk = find_task_by_vpid(pid); \
+       tsk = pid_task(find_vpid(pid), PIDTYPE_PID); \
        if (tsk) send_sig(sig, tsk, 1); \
 }
 #else
@@ -453,7 +439,6 @@ if (tsk) send_sig(sig, tsk, 1); \
        kill_proc(pid, sig, 1); \
 }
 #endif 
-#endif 
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
 #define netdev_priv(dev) dev->priv
index 46c04d379227f3b5044236d8db868ac617ac1043..1f8ecb14d97a05f62ea263595e1530e756c46b09 100644 (file)
@@ -24,7 +24,7 @@
  *
  * Dependencies: proto/bcmeth.h
  *
- * $Id: bcmevent.h,v 9.34.4.1.20.16 2009/09/25 23:52:38 Exp $
+ * $Id: bcmevent.h,v 9.34.4.1.20.16.64.1 2010/11/08 21:57:03 Exp $
  *
  */
 
@@ -131,10 +131,10 @@ typedef BWL_PRE_PACKED_STRUCT struct bcm_event {
 #define WLC_E_ACTION_FRAME      58      
 #define WLC_E_ACTION_FRAME_COMPLETE 59  
 
-#define WLC_E_ESCAN_RESULT 69               
-#define WLC_E_WAKE_EVENT       70      
-#define WLC_E_LAST             71      
-       
+#define WLC_E_ESCAN_RESULT     69
+#define WLC_E_WAKE_EVENT       70
+#define WLC_E_RELOAD           71
+#define WLC_E_LAST             72
 
 
 
@@ -205,6 +205,7 @@ typedef BWL_PRE_PACKED_STRUCT struct bcm_event {
 #define WLC_E_IF_ADD           1       
 #define WLC_E_IF_DEL           2       
 
+#define WLC_E_RELOAD_STATUS1   1
 
 #include <packed_section_end.h>
 
index 05b3fd8729737325a6c769af002068ec0e41948a..39e5c8d6aed0c11ad2fdbffd71734b0ddefdbeae 100644 (file)
@@ -1001,7 +1001,6 @@ typedef volatile struct {
 #define CST4315_CBUCK_MODE_BURST       0x00000400
 #define CST4315_CBUCK_MODE_LPBURST     0x00000c00
 
-
 #define PMU_MAX_TRANSITION_DLY 15000
 
 
diff --git a/drivers/net/wireless/bcm4319/include/spid.h b/drivers/net/wireless/bcm4319/include/spid.h
new file mode 100644 (file)
index 0000000..c740296
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * SPI device spec header file
+ *
+ * Copyright (C) 2010, Broadcom Corporation
+ * All Rights Reserved.
+ * 
+ * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
+ * the contents of this file may not be disclosed to third parties, copied
+ * or duplicated in any form, in whole or in part, without the prior
+ * written permission of Broadcom Corporation.
+ *
+ * $Id: spid.h,v 1.7.10.1.16.3 2009/04/09 19:23:14 Exp $
+ */
+
+#ifndef        _SPI_H
+#define        _SPI_H
+
+/*
+ * Brcm SPI Device Register Map.
+ *
+ */
+
+typedef volatile struct {
+       uint8   config;                 /* 0x00, len, endian, clock, speed, polarity, wakeup */
+       uint8   response_delay;         /* 0x01, read response delay in bytes (corerev < 3) */
+       uint8   status_enable;          /* 0x02, status-enable, intr with status, response_delay
+                                        * function selection, command/data error check
+                                        */
+       uint8   reset_bp;               /* 0x03, reset on wlan/bt backplane reset (corerev >= 1) */
+       uint16  intr_reg;               /* 0x04, Intr status register */
+       uint16  intr_en_reg;            /* 0x06, Intr mask register */
+       uint32  status_reg;             /* 0x08, RO, Status bits of last spi transfer */
+       uint16  f1_info_reg;            /* 0x0c, RO, enabled, ready for data transfer, blocksize */
+       uint16  f2_info_reg;            /* 0x0e, RO, enabled, ready for data transfer, blocksize */
+       uint16  f3_info_reg;            /* 0x10, RO, enabled, ready for data transfer, blocksize */
+       uint32  test_read;              /* 0x14, RO 0xfeedbead signature */
+       uint32  test_rw;                /* 0x18, RW */
+       uint8   resp_delay_f0;          /* 0x1c, read resp delay bytes for F0 (corerev >= 3) */
+       uint8   resp_delay_f1;          /* 0x1d, read resp delay bytes for F1 (corerev >= 3) */
+       uint8   resp_delay_f2;          /* 0x1e, read resp delay bytes for F2 (corerev >= 3) */
+       uint8   resp_delay_f3;          /* 0x1f, read resp delay bytes for F3 (corerev >= 3) */
+} spi_regs_t;
+
+/* SPI device register offsets */
+#define SPID_CONFIG                    0x00
+#define SPID_RESPONSE_DELAY            0x01
+#define SPID_STATUS_ENABLE             0x02
+#define SPID_RESET_BP                  0x03    /* (corerev >= 1) */
+#define SPID_INTR_REG                  0x04    /* 16 bits - Interrupt status */
+#define SPID_INTR_EN_REG               0x06    /* 16 bits - Interrupt mask */
+#define SPID_STATUS_REG                        0x08    /* 32 bits */
+#define SPID_F1_INFO_REG               0x0C    /* 16 bits */
+#define SPID_F2_INFO_REG               0x0E    /* 16 bits */
+#define SPID_F3_INFO_REG               0x10    /* 16 bits */
+#define SPID_TEST_READ                 0x14    /* 32 bits */
+#define SPID_TEST_RW                   0x18    /* 32 bits */
+#define SPID_RESP_DELAY_F0             0x1c    /* 8 bits (corerev >= 3) */
+#define SPID_RESP_DELAY_F1             0x1d    /* 8 bits (corerev >= 3) */
+#define SPID_RESP_DELAY_F2             0x1e    /* 8 bits (corerev >= 3) */
+#define SPID_RESP_DELAY_F3             0x1f    /* 8 bits (corerev >= 3) */
+
+/* Bit masks for SPID_CONFIG device register */
+#define WORD_LENGTH_32 0x1     /* 0/1 16/32 bit word length */
+#define ENDIAN_BIG     0x2     /* 0/1 Little/Big Endian */
+#define CLOCK_PHASE    0x4     /* 0/1 clock phase delay */
+#define CLOCK_POLARITY 0x8     /* 0/1 Idle state clock polarity is low/high */
+#define HIGH_SPEED_MODE        0x10    /* 1/0 High Speed mode / Normal mode */
+#define INTR_POLARITY  0x20    /* 1/0 Interrupt active polarity is high/low */
+#define WAKE_UP                0x80    /* 0/1 Wake-up command from Host to WLAN */
+
+/* Bit mask for SPID_RESPONSE_DELAY device register */
+#define RESPONSE_DELAY_MASK    0xFF    /* Configurable rd response delay in multiples of 8 bits */
+
+/* Bit mask for SPID_STATUS_ENABLE device register */
+#define STATUS_ENABLE          0x1     /* 1/0 Status sent/not sent to host after read/write */
+#define INTR_WITH_STATUS       0x2     /* 0/1 Do-not / do-interrupt if status is sent */
+#define RESP_DELAY_ALL         0x4     /* Applicability of resp delay to F1 or all func's read */
+#define DWORD_PKT_LEN_EN       0x8     /* Packet len denoted in dwords instead of bytes */
+#define CMD_ERR_CHK_EN         0x20    /* Command error check enable */
+#define DATA_ERR_CHK_EN                0x40    /* Data error check enable */
+
+/* Bit mask for SPID_RESET_BP device register */
+#define RESET_ON_WLAN_BP_RESET 0x4     /* enable reset for WLAN backplane */
+#define RESET_ON_BT_BP_RESET   0x8     /* enable reset for BT backplane */
+#define RESET_SPI              0x80    /* reset the above enabled logic */
+
+/* Bit mask for SPID_INTR_REG device register */
+#define DATA_UNAVAILABLE       0x0001  /* Requested data not available; Clear by writing a "1" */
+#define F2_F3_FIFO_RD_UNDERFLOW        0x0002
+#define F2_F3_FIFO_WR_OVERFLOW 0x0004
+#define COMMAND_ERROR          0x0008  /* Cleared by writing 1 */
+#define DATA_ERROR             0x0010  /* Cleared by writing 1 */
+#define F2_PACKET_AVAILABLE    0x0020
+#define F3_PACKET_AVAILABLE    0x0040
+#define F1_OVERFLOW            0x0080  /* Due to last write. Bkplane has pending write requests */
+#define MISC_INTR0             0x0100
+#define MISC_INTR1             0x0200
+#define MISC_INTR2             0x0400
+#define MISC_INTR3             0x0800
+#define MISC_INTR4             0x1000
+#define F1_INTR                        0x2000
+#define F2_INTR                        0x4000
+#define F3_INTR                        0x8000
+
+/* Bit mask for 32bit SPID_STATUS_REG device register */
+#define STATUS_DATA_NOT_AVAILABLE      0x00000001
+#define STATUS_UNDERFLOW               0x00000002
+#define STATUS_OVERFLOW                        0x00000004
+#define STATUS_F2_INTR                 0x00000008
+#define STATUS_F3_INTR                 0x00000010
+#define STATUS_F2_RX_READY             0x00000020
+#define STATUS_F3_RX_READY             0x00000040
+#define STATUS_HOST_CMD_DATA_ERR       0x00000080
+#define STATUS_F2_PKT_AVAILABLE                0x00000100
+#define STATUS_F2_PKT_LEN_MASK         0x000FFE00
+#define STATUS_F2_PKT_LEN_SHIFT                9
+#define STATUS_F3_PKT_AVAILABLE                0x00100000
+#define STATUS_F3_PKT_LEN_MASK         0xFFE00000
+#define STATUS_F3_PKT_LEN_SHIFT                21
+
+/* Bit mask for 16 bits SPID_F1_INFO_REG device register */
+#define F1_ENABLED                     0x0001
+#define F1_RDY_FOR_DATA_TRANSFER       0x0002
+#define F1_MAX_PKT_SIZE                        0x01FC
+
+/* Bit mask for 16 bits SPID_F2_INFO_REG device register */
+#define F2_ENABLED                     0x0001
+#define F2_RDY_FOR_DATA_TRANSFER       0x0002
+#define F2_MAX_PKT_SIZE                        0x3FFC
+
+/* Bit mask for 16 bits SPID_F3_INFO_REG device register */
+#define F3_ENABLED                     0x0001
+#define F3_RDY_FOR_DATA_TRANSFER       0x0002
+#define F3_MAX_PKT_SIZE                        0x3FFC
+
+/* Bit mask for 32 bits SPID_TEST_READ device register read in 16bit LE mode */
+#define TEST_RO_DATA_32BIT_LE          0xFEEDBEAD
+
+/* Maximum number of I/O funcs */
+#define SPI_MAX_IOFUNCS                4
+
+#define SPI_MAX_PKT_LEN                (2048*4)
+
+/* Misc defines */
+#define SPI_FUNC_0             0
+#define SPI_FUNC_1             1
+#define SPI_FUNC_2             2
+#define SPI_FUNC_3             3
+
+#define WAIT_F2RXFIFORDY       100
+#define WAIT_F2RXFIFORDY_DELAY 20
+
+#endif /* _SPI_H */
diff --git a/drivers/net/wireless/bcm4319/include/wifi_version.h b/drivers/net/wireless/bcm4319/include/wifi_version.h
new file mode 100644 (file)
index 0000000..b3ccd72
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef WIFI_VERSION_H
+#define WIFI_VERSION_H
+
+/*
+ * Broadcom BCM4319 driver version.
+ */
+#define BCM4319_DRV_VERSION "2.00"
+
+#endif /* WIFI_BCM4319_VERSION_H */
index d346945dec94fb18aa5e39bb9af3c9f9ffcb0612..cd7725a70db41d3fdd4f509fe9ba706b0747f38d 100644 (file)
@@ -24,7 +24,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wlioctl.h,v 1.601.4.15.2.14.2.61 2010/05/04 20:26:25 Exp $
+ * $Id: wlioctl.h,v 1.601.4.15.2.14.2.62.4.1 2010/11/17 03:09:28 Exp $
  */
 
 
@@ -857,6 +857,7 @@ typedef struct wl_ioctl {
 #define PM_MAX 1
 #define PM_FAST 2
 
+#define LISTEN_INTERVAL                        20
 
 #define        INTERFERE_NONE  0       
 #define        NON_WLAN        1       
@@ -1317,6 +1318,8 @@ enum {
 
 #define PFN_VERSION                    1
 
+#define MAX_PFN_LIST_COUNT     16
+
 
 typedef struct wl_pfn_param {
        int32 version;                  
index 242af39e0caa42f4d654646e4328f259c567102e..980416baf918c75482136812fcbe0b254959274a 100644 (file)
@@ -26,9 +26,7 @@
 
 
 #define LINUX_OSL
-#if defined(CHROMIUMOS_COMPAT_WIRELESS)
-#include <linux/sched.h>
-#endif
+
 #include <typedefs.h>
 #include <bcmendian.h>
 #include <linuxver.h>
@@ -37,6 +35,7 @@
 #include <bcmutils.h>
 #include <linux/delay.h>
 #include <pcicfg.h>
+#include <linux/mutex.h>
 
 #define PCI_CFG_RETRY          10
 
@@ -48,7 +47,7 @@
 #define STATIC_BUF_SIZE        (PAGE_SIZE*2)
 #define STATIC_BUF_TOTAL_LEN (MAX_STATIC_BUF_NUM*STATIC_BUF_SIZE)
 typedef struct bcm_static_buf {
-       struct semaphore static_sem;
+       struct mutex static_sem;
        unsigned char *buf_ptr;
        unsigned char buf_use[MAX_STATIC_BUF_NUM];
 } bcm_static_buf_t;
@@ -59,7 +58,7 @@ static bcm_static_buf_t *bcm_static_buf = 0;
 typedef struct bcm_static_pkt {
        struct sk_buff *skb_4k[MAX_STATIC_PKT_NUM];
        struct sk_buff *skb_8k[MAX_STATIC_PKT_NUM];
-       struct semaphore osl_pkt_sem;
+       struct mutex osl_pkt_sem;
        unsigned char pkt_use[MAX_STATIC_PKT_NUM*2];
 } bcm_static_pkt_t;
 static bcm_static_pkt_t *bcm_static_skb = 0;
@@ -153,8 +152,10 @@ osl_t *
 osl_attach(void *pdev, uint bustype, bool pkttag)
 {
        osl_t *osh;
+       gfp_t flags;
 
-       osh = kmalloc(sizeof(osl_t), GFP_ATOMIC);
+       flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL;
+       osh = kmalloc(sizeof(osl_t), flags);
        ASSERT(osh);
 
        bzero(osh, sizeof(osl_t));
@@ -195,11 +196,11 @@ osl_attach(void *pdev, uint bustype, bool pkttag)
                        STATIC_BUF_TOTAL_LEN))) {
                        printk("can not alloc static buf!\n");
                }
-               else
-                       printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf);
-
+               else {
+                       /* printk("alloc static buf at %x!\n", (unsigned int)bcm_static_buf); */
+               }
                
-               init_MUTEX(&bcm_static_buf->static_sem);
+               mutex_init(&bcm_static_buf->static_sem);
 
                
                bcm_static_buf->buf_ptr = (unsigned char *)bcm_static_buf + STATIC_BUF_SIZE;
@@ -217,7 +218,7 @@ osl_attach(void *pdev, uint bustype, bool pkttag)
                for (i = 0; i < MAX_STATIC_PKT_NUM*2; i++)
                        bcm_static_skb->pkt_use[i] = 0;
 
-               init_MUTEX(&bcm_static_skb->osl_pkt_sem);
+               mutex_init(&bcm_static_skb->osl_pkt_sem);
        }
 #endif 
        return osh;
@@ -304,7 +305,7 @@ osl_pktget_static(osl_t *osh, uint len)
        }
 
        
-       down(&bcm_static_skb->osl_pkt_sem);
+       mutex_lock(&bcm_static_skb->osl_pkt_sem);
        if (len <= PAGE_SIZE)
        {
                
@@ -317,7 +318,7 @@ osl_pktget_static(osl_t *osh, uint len)
                if (i != MAX_STATIC_PKT_NUM)
                {
                        bcm_static_skb->pkt_use[i] = 1;
-                       up(&bcm_static_skb->osl_pkt_sem);
+                       mutex_unlock(&bcm_static_skb->osl_pkt_sem);
 
                        skb = bcm_static_skb->skb_4k[i];
                        skb->tail = skb->data + len;
@@ -337,7 +338,7 @@ osl_pktget_static(osl_t *osh, uint len)
        if (i != MAX_STATIC_PKT_NUM)
        {
                bcm_static_skb->pkt_use[i+MAX_STATIC_PKT_NUM] = 1;
-               up(&bcm_static_skb->osl_pkt_sem);
+               mutex_unlock(&bcm_static_skb->osl_pkt_sem);
                skb = bcm_static_skb->skb_8k[i];
                skb->tail = skb->data + len;
                skb->len = len;
@@ -347,7 +348,7 @@ osl_pktget_static(osl_t *osh, uint len)
 
 
        
-       up(&bcm_static_skb->osl_pkt_sem);
+       mutex_unlock(&bcm_static_skb->osl_pkt_sem);
        printk("all static pkt in use!\n");
        return osl_pktget(osh, len);
 }
@@ -362,9 +363,9 @@ osl_pktfree_static(osl_t *osh, void *p, bool send)
        {
                if (p == bcm_static_skb->skb_4k[i])
                {
-                       down(&bcm_static_skb->osl_pkt_sem);
+                       mutex_lock(&bcm_static_skb->osl_pkt_sem);
                        bcm_static_skb->pkt_use[i] = 0;
-                       up(&bcm_static_skb->osl_pkt_sem);
+                       mutex_unlock(&bcm_static_skb->osl_pkt_sem);
 
                        
                        return;
@@ -455,8 +456,8 @@ void*
 osl_malloc(osl_t *osh, uint size)
 {
        void *addr;
+       gfp_t flags;
 
-       
        if (osh)
                ASSERT(osh->magic == OS_HANDLE_MAGIC);
 
@@ -466,7 +467,7 @@ osl_malloc(osl_t *osh, uint size)
                int i = 0;
                if ((size >= PAGE_SIZE)&&(size <= STATIC_BUF_SIZE))
                {
-                       down(&bcm_static_buf->static_sem);
+                       mutex_lock(&bcm_static_buf->static_sem);
                        
                        for (i = 0; i < MAX_STATIC_BUF_NUM; i++)
                        {
@@ -476,13 +477,13 @@ osl_malloc(osl_t *osh, uint size)
                        
                        if (i == MAX_STATIC_BUF_NUM)
                        {
-                               up(&bcm_static_buf->static_sem);
+                               mutex_unlock(&bcm_static_buf->static_sem);
                                printk("all static buff in use!\n");
                                goto original;
                        }
                        
                        bcm_static_buf->buf_use[i] = 1;
-                       up(&bcm_static_buf->static_sem);
+                       mutex_unlock(&bcm_static_buf->static_sem);
 
                        bzero(bcm_static_buf->buf_ptr+STATIC_BUF_SIZE*i, size);
                        if (osh)
@@ -493,8 +494,8 @@ osl_malloc(osl_t *osh, uint size)
        }
 original:
 #endif 
-
-       if ((addr = kmalloc(size, GFP_ATOMIC)) == NULL) {
+       flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL;
+       if ((addr = kmalloc(size, flags)) == NULL) {
                if (osh)
                        osh->failed++;
                return (NULL);
@@ -518,9 +519,9 @@ osl_mfree(osl_t *osh, void *addr, uint size)
                        
                        buf_idx = ((unsigned char *)addr - bcm_static_buf->buf_ptr)/STATIC_BUF_SIZE;
                        
-                       down(&bcm_static_buf->static_sem);
+                       mutex_lock(&bcm_static_buf->static_sem);
                        bcm_static_buf->buf_use[buf_idx] = 0;
-                       up(&bcm_static_buf->static_sem);
+                       mutex_unlock(&bcm_static_buf->static_sem);
 
                        if (osh) {
                                ASSERT(osh->magic == OS_HANDLE_MAGIC);
@@ -606,8 +607,10 @@ void *
 osl_pktdup(osl_t *osh, void *skb)
 {
        void * p;
+       gfp_t flags;
 
-       if ((p = skb_clone((struct sk_buff*)skb, GFP_ATOMIC)) == NULL)
+       flags = (in_atomic()) ? GFP_ATOMIC : GFP_KERNEL;
+       if ((p = skb_clone((struct sk_buff*)skb, flags)) == NULL)
                return NULL;
 
        
diff --git a/drivers/net/wireless/bcm4319/mkclean.sh b/drivers/net/wireless/bcm4319/mkclean.sh
deleted file mode 100755 (executable)
index 2fcad1b..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-rm -f *.o
-rm -f ../wifi_power/*.o
-rm -f *.uu
-rm -rf bcm4319
-rm -f .*.cmd
-rm -f ../wifi_power/.*.cmd
-rm -f modules.order Module.symvers
-
-find . -name '*.o' -exec rm -f {} \;
-find . -name '.*.cmd' -exec rm -f {} \;
-
diff --git a/drivers/net/wireless/bcm4319/mkpkg.sh b/drivers/net/wireless/bcm4319/mkpkg.sh
deleted file mode 100755 (executable)
index 224f914..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-echo "Begin to make BCM4319 wifi driver package ..."
-
-RKWLCFGDIR=../wifi_power
-PKGNAME="bcm4319"
-RKPUB="rkpub"
-PKGVER=`grep -r '#define BCM4319_DRV_VERSION' ${RKWLCFGDIR}/wifi_version.h | sed 's/[^"]*\"\([0-9A-Za-z\.]*\)*\"/\1/'`
-
-[ `dirname $0` = '.' ] || exit
-
-
-rm -rf ${RKPUB}
-mkdir -p ${RKPUB}/${PKGNAME}
-
-cp Makefile.${PKGNAME} ${RKPUB}/${PKGNAME}/Makefile
-cp Kconfig.${PKGNAME} ${RKPUB}/${PKGNAME}/Kconfig
-cp ${RKWLCFGDIR}/wifi_power.c ${RKPUB}/${PKGNAME}/wifi_power.c
-cp ${RKWLCFGDIR}/wifi_power.h ${RKPUB}/${PKGNAME}/wifi_power.h
-cp ${RKWLCFGDIR}/wifi_version.h ${RKPUB}/${PKGNAME}/wifi_version.h
-chmod 644 ${RKPUB}/${PKGNAME}/*
-cp -dpR firmware ${RKPUB}/${PKGNAME}/
-find ${RKPUB}/${PKGNAME}/firmware -type d -name '.svn' | xargs rm -rf
-uuencode ${PKGNAME}.o ${PKGNAME}.o > ${RKPUB}/${PKGNAME}/${PKGNAME}.uu
-cd ${RKPUB} && tar -jcvf ${PKGNAME}-${PKGVER}.tar.bz2 ${PKGNAME}
-
-echo "Done"
index 03439718beea417a372b709f74dfb3c45e8bdbc8..81491cb97746407df001d606d4a44c7ceabe97fa 100644 (file)
@@ -3165,8 +3165,8 @@ wl_get_iscan_results(struct wl_iscan_ctrl *iscan, uint32 *status, struct wl_scan
        results->buflen = dtoh32(results->buflen);
        results->version = dtoh32(results->version);
        results->count = dtoh32(results->count);
-       //WL_DBG(("results->count = %d\n", results->count));
-       //WL_DBG(("results->buflen = %d\n", results->buflen));
+       WL_DBG(("results->count = %d\n", results->count));
+       WL_DBG(("results->buflen = %d\n", results->buflen));
        *status = dtoh32(list_buf->status);
        *bss_list = results;
 
index c25cf2c8e38f286627e0d4c5ea68a78a1121cb06..146dffd529764dab9e4257b9d633146e12cc6ca6 100644 (file)
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_iw.c,v 1.51.4.9.2.6.4.124 2010/07/27 20:46:02 Exp $
+ * $Id: wl_iw.c,v 1.51.4.9.2.6.4.142.4.69 2010/12/21 03:00:08 Exp $
  */
 
-#include <wlioctl.h>
 
 #include <typedefs.h>
 #include <linuxver.h>
@@ -49,15 +48,17 @@ typedef const struct si_pub  si_t;
 #include <proto/ethernet.h>
 #include <dngl_stats.h>
 #include <dhd.h>
-#include <dhd_dbg.h>
-#define WL_ERROR(x) DHD_ERROR(x)
-#define WL_TRACE(x) DHD_TRACE(x)
+#define WL_ERROR(x) printf x
+#define WL_TRACE(x)
 #define WL_ASSOC(x)
 #define WL_INFORM(x)
 #define WL_WSEC(x)
 #define WL_SCAN(x)
+#define WL_TRACE_COEX(x)
 
 #include <wl_iw.h>
+#include <linux/wakelock.h>
+
 
 #ifndef IW_ENCODE_ALG_SM4
 #define IW_ENCODE_ALG_SM4 0x20
@@ -87,25 +88,23 @@ typedef const struct si_pub  si_t;
 #define IW_WSEC_ENABLED(wsec)  ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED | SMS4_ENABLED))
 
 #include <linux/rtnetlink.h>
+#include <linux/mutex.h>
 
 #define WL_IW_USE_ISCAN  1
 #define ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS  1
 
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       struct mutex  g_wl_ss_scan_lock; 
-#endif 
-
 #if defined(SOFTAP)
-#define WL_SOFTAP(x) DHD_TRACE(x)
+#define WL_SOFTAP(x) printk x
 static struct net_device *priv_dev;
-static bool    ap_cfg_running = FALSE;
-static bool    ap_fw_loaded = FALSE;
+static bool ap_cfg_running = FALSE;
+bool ap_fw_loaded = FALSE;
+static long ap_cfg_pid = -1;
 struct net_device *ap_net_dev = NULL;
 struct semaphore  ap_eth_sema;
+static struct completion ap_cfg_exited;
 static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap);
-static int wl_iw_softap_deassoc_stations(struct net_device *dev);
-#endif 
+static int wl_iw_softap_deassoc_stations(struct net_device *dev, u8 *mac);
+#endif
 
 #define WL_IW_IOCTL_CALL(func_call) \
        do {                            \
@@ -113,6 +112,12 @@ static int wl_iw_softap_deassoc_stations(struct net_device *dev);
        } while (0)
 
 static int             g_onoff = G_WLAN_SET_ON;
+wl_iw_extra_params_t   g_wl_iw_params;
+static struct mutex    wl_cache_lock;
+
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+static bool use_non_dfs_channels = true;
+#endif
 
 extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
        uint32 reason, char* stringBuf, uint buflen);
@@ -126,6 +131,7 @@ uint wl_msg_level = WL_ERROR_VAL;
 
 #define MAX_WLIW_IOCTL_LEN 1024
 
+
 #if defined(IL_BIGENDIAN)
 #include <bcmendian.h>
 #define htod32(i) (bcmswap32(i))
@@ -161,7 +167,12 @@ static wlc_ssid_t g_specific_ssid;
 static wlc_ssid_t g_ssid;
 
 static wl_iw_ss_cache_ctrl_t g_ss_cache_ctrl;  
-static volatile uint g_first_broadcast_scan;   
+#if defined(CONFIG_FIRST_SCAN)
+static volatile uint g_first_broadcast_scan;
+static volatile uint g_first_counter_scans;
+#define MAX_ALLOWED_BLOCK_SCAN_FROM_FIRST_SCAN 3
+#endif
+
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
 #define DAEMONIZE(a) daemonize(a); \
@@ -177,11 +188,13 @@ static volatile uint g_first_broadcast_scan;
 #endif 
 
 #if defined(WL_IW_USE_ISCAN)
-#if  !defined(CSCAN)
+#if !defined(CSCAN)
 static void wl_iw_free_ss_cache(void);
 static int   wl_iw_run_ss_cache_timer(int kick_off);
-#endif 
+#endif
+#if defined(CONFIG_FIRST_SCAN)
 int  wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
+#endif
 static int dev_wlc_bufvar_set(struct net_device *dev, char *name, char *buf, int len);
 #define ISCAN_STATE_IDLE   0
 #define ISCAN_STATE_SCANING 1
@@ -200,6 +213,7 @@ typedef struct iscan_info {
        int    iscan_state;
        iscan_buf_t * list_hdr;
        iscan_buf_t * list_cur;
+
        
        long sysioc_pid;
        struct semaphore sysioc_sem;
@@ -210,12 +224,16 @@ typedef struct iscan_info {
        char ioctlbuf[WLC_IOCTL_MEDLEN];
 #else
        char ioctlbuf[WLC_IOCTL_SMLEN];
-#endif 
-       
+#endif
        wl_iscan_params_t *iscan_ex_params_p;
        int iscan_ex_param_size;
 } iscan_info_t;
-#define  COEX_DHCP 1 
+#define COEX_DHCP 1
+
+#define BT_DHCP_eSCO_FIX
+#define BT_DHCP_USE_FLAGS
+#define BT_DHCP_OPPORTUNITY_WINDOW_TIME         2500
+#define BT_DHCP_FLAG_FORCE_TIME 5500
 static void wl_iw_bt_flag_set(struct net_device *dev, bool set);
 static void wl_iw_bt_release(void);
 
@@ -225,18 +243,16 @@ typedef enum bt_coex_status {
        BT_DHCP_OPPORTUNITY_WINDOW,
        BT_DHCP_FLAG_FORCE_TIMEOUT
 } coex_status_t;
-#define BT_DHCP_OPPORTUNITY_WINDOW_TIEM        2500    
-#define BT_DHCP_FLAG_FORCE_TIME                                5500    
 
 typedef struct bt_info {
        struct net_device *dev;
        struct timer_list timer;
        uint32 timer_ms;
        uint32 timer_on;
-       int     bt_state;
+       bool   dhcp_done;
+       int    bt_state;
 
-       
-       long bt_pid;
+       long   bt_pid;
        struct semaphore bt_sem;
        struct completion bt_exited;
 } bt_info_t;
@@ -256,6 +272,8 @@ wl_iw_set_scan(
        union iwreq_data *wrqu,
        char *extra
 );
+
+#ifndef CSCAN
 static int
 wl_iw_get_scan(
        struct net_device *dev,
@@ -271,7 +289,7 @@ wl_iw_get_scan_prep(
        char *extra,
        short max_size
 );
-
+#endif
 
 static void swap_key_from_BE(
                wl_wsec_key_t *key
@@ -299,7 +317,9 @@ static void swap_key_to_BE(
        key->iv_initialized = dtoh32(key->iv_initialized);
 }
 
-static int dev_wlc_ioctl(      struct net_device *dev,
+static int
+dev_wlc_ioctl(
+       struct net_device *dev,
        int cmd,
        void *arg,
        int len
@@ -315,11 +335,12 @@ static int dev_wlc_ioctl( struct net_device *dev,
                return ret;
        }
 
+       net_os_wake_lock(dev);
+
        WL_INFORM(("\n%s, PID:%x: send Local IOCTL -> dhd: cmd:0x%x, buf:%p, len:%d ,\n",
                __FUNCTION__, current->pid, cmd, arg, len));
 
-       if (g_onoff == G_WLAN_SET_ON) 
-       {
+       if (g_onoff == G_WLAN_SET_ON) {
                memset(&ioc, 0, sizeof(ioc));
                ioc.cmd = cmd;
                ioc.buf = arg;
@@ -328,29 +349,32 @@ static int dev_wlc_ioctl( struct net_device *dev,
                strcpy(ifr.ifr_name, dev->name);
                ifr.ifr_data = (caddr_t) &ioc;
 
-               
                ret = dev_open(dev);
                if (ret) {
                        WL_ERROR(("%s: Error dev_open: %d\n", __func__, ret));
+                       net_os_wake_unlock(dev);
                        return ret;
                }
 
                fs = get_fs();
                set_fs(get_ds());
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
-               //printk("Calling dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE)\n");
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 31))
                ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
 #else
                ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#endif 
+#endif
                set_fs(fs);
        }
        else {
                WL_TRACE(("%s: call after driver stop : ignored\n", __FUNCTION__));
        }
+
+       net_os_wake_unlock(dev);
+
        return ret;
 }
 
+
 static int
 dev_wlc_intvar_get_reg(
        struct net_device *dev,
@@ -391,8 +415,6 @@ dev_wlc_intvar_set_reg(
 }
 
 
-
-
 static int
 dev_wlc_intvar_set(
        struct net_device *dev,
@@ -456,11 +478,7 @@ dev_wlc_bufvar_set(
        char *name,
        char *buf, int len)
 {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
-       char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
        static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif 
        uint buflen;
 
        buflen = bcm_mkiovar(name, buf, len, ioctlbuf, sizeof(ioctlbuf));
@@ -468,7 +486,7 @@ dev_wlc_bufvar_set(
 
        return (dev_wlc_ioctl(dev, WLC_SET_VAR, ioctlbuf, buflen));
 }
-#endif 
+#endif
 
 
 static int
@@ -477,11 +495,7 @@ dev_wlc_bufvar_get(
        char *name,
        char *buf, int buflen)
 {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
-       char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
        static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif 
        int error;
        uint len;
 
@@ -605,7 +619,31 @@ wl_iw_get_macaddr(
        return error;
 }
 
+static int
+wl_iw_set_country_code(struct net_device *dev, char *ccode)
+{
+       char country_code[WLC_CNTRY_BUF_SZ];
+       int ret = -1;
 
+       WL_TRACE(("%s\n", __FUNCTION__));
+       if (!ccode)
+               ccode = dhd_bus_country_get(dev);
+       strncpy(country_code, ccode, sizeof(country_code));
+       if (ccode && (country_code[0] != 0)) {
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+               if (use_non_dfs_channels && !strncmp(country_code, "US", 2))
+                       strncpy(country_code, "Q2", WLC_CNTRY_BUF_SZ);
+               if (!use_non_dfs_channels && !strncmp(country_code, "Q2", 2))
+                       strncpy(country_code, "US", WLC_CNTRY_BUF_SZ);
+#endif
+               ret = dev_wlc_ioctl(dev, WLC_SET_COUNTRY, &country_code, sizeof(country_code));
+               if (ret >= 0) {
+                       WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
+                       dhd_bus_country_set(dev, &country_code[0]);
+               }
+       }
+       return ret;
+}
 
 static int
 wl_iw_set_country(
@@ -621,20 +659,17 @@ wl_iw_set_country(
        int country_offset;
        int country_code_size;
 
+       WL_TRACE(("%s\n", __FUNCTION__));
        memset(country_code, 0, sizeof(country_code));
 
-       
        country_offset = strcspn(extra, " ");
        country_code_size = strlen(extra) - country_offset;
 
-       
        if (country_offset != 0) {
-               strncpy(country_code, extra + country_offset +1,
+               strncpy(country_code, extra + country_offset + 1,
                        MIN(country_code_size, sizeof(country_code)));
-
-               
-               if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
-                       &country_code, sizeof(country_code))) >= 0) {
+               error = wl_iw_set_country_code(dev, country_code);
+               if (error >= 0) {
                        p += snprintf(p, MAX_WX_STRING, "OK");
                        WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
                        goto exit;
@@ -649,6 +684,33 @@ exit:
        return error;
 }
 
+static int
+wl_iw_get_country(
+        struct net_device *dev,
+        struct iw_request_info *info,
+        union iwreq_data *wrqu,
+        char *extra
+)
+{
+       char *ccode;
+       int current_channels;
+       
+       WL_TRACE(("%s\n", __FUNCTION__));
+
+       ccode = dhd_bus_country_get(dev);
+       if(ccode){
+               if(0 == strcmp(ccode, "Q2"))
+                       current_channels = 11;
+               else if(0 == strcmp(ccode, "EU"))
+                       current_channels = 13;
+               else if(0 == strcmp(ccode, "JP"))
+                       current_channels = 14;
+       }
+       sprintf(extra, "Scan-Channels = %d", current_channels);
+       printk("Get Channels return %d,(country code = %s)\n",current_channels, ccode); 
+       return 0;
+}
+
 #ifdef CUSTOMER_HW2
 static int
 wl_iw_set_power_mode(
@@ -660,28 +722,38 @@ wl_iw_set_power_mode(
 {
        int error = 0;
        char *p = extra;
-       static int  pm = PM_FAST;
-       int  pm_local = PM_OFF;
+       static int pm = PM_FAST;
+       int pm_local = PM_OFF;
        char powermode_val = 0;
 
-       strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
+       WL_TRACE_COEX(("%s: DHCP session cmd:%s\n", __FUNCTION__, extra));
 
-       if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
+       strncpy((char *)&powermode_val, extra + strlen("POWERMODE") + 1, 1);
 
-               WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
+       if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
 
                dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm));
                dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
-       }
-       else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
 
-               WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
+               /* Disable packet filtering if necessary */
+               net_os_set_packet_filter(dev, 0);
+
+               g_bt->dhcp_done = false;
+               WL_TRACE_COEX(("%s: DHCP start, pm:%d changed to pm:%d\n",
+                       __FUNCTION__, pm, pm_local));
 
+       } else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
 
                dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
-       }
-       else {
-               WL_ERROR(("Unkwown yet power setting, ignored\n"));
+
+               /* Enable packet filtering if was turned off */
+               net_os_set_packet_filter(dev, 1);
+
+               g_bt->dhcp_done = true;
+
+       } else {
+               WL_ERROR(("%s Unkwown yet power setting, ignored\n",
+                       __FUNCTION__));
        }
 
        p += snprintf(p, MAX_WX_STRING, "OK");
@@ -690,7 +762,153 @@ wl_iw_set_power_mode(
 
        return error;
 }
-#endif 
+#endif
+
+
+static bool btcoex_is_sco_active(struct net_device *dev)
+{
+       int ioc_res = 0;
+       bool res = false;
+       int temp = 0;
+
+       ioc_res = dev_wlc_intvar_get_reg(dev, "btc_params", 4, &temp);
+
+       if (ioc_res == 0) {
+               WL_TRACE_COEX(("%s: read btc_params[4] = %x\n", __FUNCTION__, temp));
+
+               if ((temp > 0xea0) && (temp < 0xed8)) {
+                       WL_TRACE_COEX(("%s: BT SCO/eSCO is ACTIVE\n", __FUNCTION__));
+                       res = true;
+               } else {
+                       WL_TRACE_COEX(("%s: BT SCO/eSCO is NOT detected\n", __FUNCTION__));
+               }
+       } else {
+               WL_ERROR(("%s ioc read btc params error\n", __FUNCTION__));
+       }
+       return res;
+}
+
+#if defined(BT_DHCP_eSCO_FIX)
+
+static int set_btc_esco_params(struct net_device *dev, bool trump_sco)
+{
+       static bool saved_status = false;
+
+       char buf_reg50va_dhcp_on[8] = { 50, 00, 00, 00, 0x22, 0x80, 0x00, 0x00 };
+       char buf_reg51va_dhcp_on[8] = { 51, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+       char buf_reg64va_dhcp_on[8] = { 64, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+       char buf_reg65va_dhcp_on[8] = { 65, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+       char buf_reg71va_dhcp_on[8] = { 71, 00, 00, 00, 0x00, 0x00, 0x00, 0x00 };
+
+       uint32 regaddr;
+       static uint32 saved_reg50;
+       static uint32 saved_reg51;
+       static uint32 saved_reg64;
+       static uint32 saved_reg65;
+       static uint32 saved_reg71;
+
+       if (trump_sco) {
+
+               WL_TRACE_COEX(("Do new SCO/eSCO coex algo {save & override} \n"));
+
+               if  ((!dev_wlc_intvar_get_reg(dev, "btc_params", 50,  &saved_reg50)) &&
+                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 51,  &saved_reg51)) &&
+                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 64,  &saved_reg64)) &&
+                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 65,  &saved_reg65)) &&
+                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 71,  &saved_reg71))) {
+
+                       saved_status = TRUE;
+                       WL_TRACE_COEX(("%s saved bt_params[50,51,64,65,71]:"
+                               " 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+                               __FUNCTION__, saved_reg50, saved_reg51,
+                               saved_reg64, saved_reg65, saved_reg71));
+
+               } else {
+                       WL_ERROR((":%s: save btc_params failed\n",
+                               __FUNCTION__));
+                       saved_status = false;
+                       return -1;
+               }
+
+               WL_TRACE_COEX(("override with [50,51,64,65,71]:"
+                       " 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+                       *(u32 *)(buf_reg50va_dhcp_on+4),
+                       *(u32 *)(buf_reg51va_dhcp_on+4),
+                       *(u32 *)(buf_reg64va_dhcp_on+4),
+                       *(u32 *)(buf_reg65va_dhcp_on+4),
+                       *(u32 *)(buf_reg71va_dhcp_on+4)));
+
+               dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg50va_dhcp_on[0], 8);
+               dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg51va_dhcp_on[0], 8);
+               dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg64va_dhcp_on[0], 8);
+               dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg65va_dhcp_on[0], 8);
+               dev_wlc_bufvar_set(dev, "btc_params", (char *)&buf_reg71va_dhcp_on[0], 8);
+
+               saved_status = true;
+
+       } else if (saved_status) {
+
+               WL_TRACE_COEX(("Do new SCO/eSCO coex algo {save & override} \n"));
+
+               regaddr = 50;
+               dev_wlc_intvar_set_reg(dev, "btc_params",
+                       (char *)&regaddr, (char *)&saved_reg50);
+               regaddr = 51;
+               dev_wlc_intvar_set_reg(dev, "btc_params",
+                       (char *)&regaddr, (char *)&saved_reg51);
+               regaddr = 64;
+               dev_wlc_intvar_set_reg(dev, "btc_params",
+                       (char *)&regaddr, (char *)&saved_reg64);
+               regaddr = 65;
+               dev_wlc_intvar_set_reg(dev, "btc_params",
+                       (char *)&regaddr, (char *)&saved_reg65);
+               regaddr = 71;
+               dev_wlc_intvar_set_reg(dev, "btc_params",
+                       (char *)&regaddr, (char *)&saved_reg71);
+
+               WL_TRACE_COEX(("restore bt_params[50,51,64,65,71]: 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+                       saved_reg50, saved_reg51, saved_reg64,
+                       saved_reg65, saved_reg71));
+
+               saved_status = false;
+       } else {
+               WL_ERROR((":%s att to restore not saved BTCOEX params\n",
+                       __FUNCTION__));
+               return -1;
+       }
+       return 0;
+}
+#endif
+
+static int
+wl_iw_get_power_mode(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       int error;
+       char *p = extra;
+       int pm_local = PM_FAST;
+
+       error = dev_wlc_ioctl(dev, WLC_GET_PM, &pm_local, sizeof(pm_local));
+       if (!error) {
+               WL_TRACE(("%s: Powermode = %d\n", __func__, pm_local));
+               if (pm_local == PM_OFF)
+                       pm_local = 1; /* Active */
+               else
+                       pm_local = 0; /* Auto */
+               p += snprintf(p, MAX_WX_STRING, "powermode = %d", pm_local);
+       }
+       else {
+               WL_TRACE(("%s: Error = %d\n", __func__, error));
+               p += snprintf(p, MAX_WX_STRING, "FAIL");
+       }
+       wrqu->data.length = p - extra + 1;
+       return error;
+}
+
 static int
 wl_iw_set_btcoex_dhcp(
        struct net_device *dev,
@@ -717,97 +935,84 @@ wl_iw_set_btcoex_dhcp(
        static bool saved_status = FALSE;
 
        char buf_flag7_default[8] =   { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-#ifndef CUSTOMER_HW2
-       uint32 temp1, temp2;
-#endif 
 
-       
-#ifdef  CUSTOMER_HW2
-       strncpy((char *)&powermode_val, extra + strlen("BTCOEXMODE") +1, 1);
+#ifdef CUSTOMER_HW2
+       strncpy((char *)&powermode_val, extra + strlen("BTCOEXMODE") + 1, 1);
 #else
-       strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
+       strncpy((char *)&powermode_val, extra + strlen("POWERMODE") + 1, 1);
 #endif
 
        if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
 
-               WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
+               WL_TRACE_COEX(("%s: DHCP session start, cmd:%s\n", __FUNCTION__, extra));
 
-               
                if ((saved_status == FALSE) &&
 #ifndef CUSTOMER_HW2
-                       (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
+                  (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
 #endif
-                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 66,  &saved_reg66)) &&
-                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 41,  &saved_reg41)) &&
-                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 68,  &saved_reg68)))   {
-                               saved_status = TRUE;
-                               WL_TRACE(("Saved 0x%x 0x%x 0x%x\n", \
-                                       saved_reg66, saved_reg41, saved_reg68));
+                  (!dev_wlc_intvar_get_reg(dev, "btc_params", 66,  &saved_reg66)) &&
+                  (!dev_wlc_intvar_get_reg(dev, "btc_params", 41,  &saved_reg41)) &&
+                  (!dev_wlc_intvar_get_reg(dev, "btc_params", 68,  &saved_reg68))) {
+                       WL_TRACE_COEX(("save regs {66,41,68} ->: 0x%x 0x%x 0x%x\n", \
+                               saved_reg66, saved_reg41, saved_reg68));
 
-                               
 #ifndef CUSTOMER_HW2
-                               dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
+                       dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
 #endif
 
-                               
-                               dev_wlc_bufvar_set(dev, "btc_params", \
-                                       (char *)&buf_reg66va_dhcp_on[0], \
+                               if (btcoex_is_sco_active(dev)) {
+
+                                       dev_wlc_bufvar_set(dev, "btc_params", \
+                                               (char *)&buf_reg66va_dhcp_on[0], \
                                                 sizeof(buf_reg66va_dhcp_on));
-                               
-                               dev_wlc_bufvar_set(dev, "btc_params", \
-                                       (char *)&buf_reg41va_dhcp_on[0], \
+
+                                       dev_wlc_bufvar_set(dev, "btc_params", \
+                                               (char *)&buf_reg41va_dhcp_on[0], \
                                                 sizeof(buf_reg41va_dhcp_on));
-                               
-                               dev_wlc_bufvar_set(dev, "btc_params", \
-                                       (char *)&buf_reg68va_dhcp_on[0], \
+
+                                       dev_wlc_bufvar_set(dev, "btc_params", \
+                                               (char *)&buf_reg68va_dhcp_on[0], \
                                                 sizeof(buf_reg68va_dhcp_on));
-                               
-#ifndef CUSTOMER_HW2
-                               if ((!dev_wlc_intvar_get_reg(dev, "btc_params", 12, &temp1)) &&
-                                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 13, &temp2)))
-                               {
-                                       if ((temp1 != 0) && (temp2 != 0)) {
-#endif
-                                               g_bt->bt_state = BT_DHCP_START;
-                                               g_bt->timer_on = 1;
-                                               mod_timer(&g_bt->timer, g_bt->timer.expires);
-                                               WL_TRACE(("%s enable BT DHCP Timer\n", \
-                                                       __FUNCTION__));
-#ifndef CUSTOMER_HW2
-                                       }
-                               }
-#endif
+                                       saved_status = TRUE;
+
+                                       g_bt->bt_state = BT_DHCP_START;
+                                       g_bt->timer_on = 1;
+                                       mod_timer(&g_bt->timer, g_bt->timer.expires);
+                                       WL_TRACE_COEX(("%s enable BT DHCP Timer\n", \
+                                       __FUNCTION__));
+                       }
                }
                else if (saved_status == TRUE) {
                        WL_ERROR(("%s was called w/o DHCP OFF. Continue\n", __FUNCTION__));
                }
        }
-#ifdef  CUSTOMER_HW2
+#ifdef CUSTOMER_HW2
        else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {
 #else
        else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
 #endif
 
-               WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
-
-               
 #ifndef CUSTOMER_HW2
                dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
 #endif
 
-               
-               WL_TRACE(("%s disable BT DHCP Timer\n", __FUNCTION__));
+               WL_TRACE_COEX(("%s disable BT DHCP Timer\n", __FUNCTION__));
                if (g_bt->timer_on) {
                        g_bt->timer_on = 0;
                        del_timer_sync(&g_bt->timer);
+
+                       if (g_bt->bt_state != BT_DHCP_IDLE) {
+                               WL_TRACE_COEX(("%s bt->bt_state:%d\n",
+                                       __FUNCTION__, g_bt->bt_state));
+
+                               up(&g_bt->bt_sem);
+                       }
                }
 
-               
-               dev_wlc_bufvar_set(dev, "btc_flags", \
+               if (saved_status == TRUE) {
+                       dev_wlc_bufvar_set(dev, "btc_flags", \
                                (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
 
-               
-               if (saved_status) {
                        regaddr = 66;
                        dev_wlc_intvar_set_reg(dev, "btc_params", \
                                (char *)&regaddr, (char *)&saved_reg66);
@@ -817,12 +1022,15 @@ wl_iw_set_btcoex_dhcp(
                        regaddr = 68;
                        dev_wlc_intvar_set_reg(dev, "btc_params", \
                                (char *)&regaddr, (char *)&saved_reg68);
+
+                       WL_TRACE_COEX(("restore regs {66,41,68} <- 0x%x 0x%x 0x%x\n", \
+                                       saved_reg66, saved_reg41, saved_reg68));
                }
                saved_status = FALSE;
-
        }
        else {
-               WL_ERROR(("Unkwown yet power setting, ignored\n"));
+               WL_ERROR(("%s Unkwown yet power setting, ignored\n",
+                       __FUNCTION__));
        }
 
        p += snprintf(p, MAX_WX_STRING, "OK");
@@ -832,6 +1040,52 @@ wl_iw_set_btcoex_dhcp(
        return error;
 }
 
+static int
+wl_iw_set_suspend(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       int suspend_flag;
+       int ret_now;
+       int ret = 0;
+
+       suspend_flag = *(extra + strlen(SETSUSPEND_CMD) + 1) - '0';
+
+       if (suspend_flag != 0)
+               suspend_flag = 1;
+
+       ret_now = net_os_set_suspend_disable(dev, suspend_flag);
+
+       if (ret_now != suspend_flag) {
+               if (!(ret = net_os_set_suspend(dev, ret_now)))
+                       WL_ERROR(("%s: Suspend Flag %d -> %d\n", \
+                                       __FUNCTION__, ret_now, suspend_flag));
+               else
+                       WL_ERROR(("%s: failed %d\n", __FUNCTION__, ret));
+       }
+
+       return ret;
+}
+
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+static int
+wl_iw_set_dfs_channels(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       use_non_dfs_channels = *(extra + strlen(SETDFSCHANNELS_CMD) + 1) - '0';
+       use_non_dfs_channels = (use_non_dfs_channels != 0) ? false : true;
+       wl_iw_set_country_code(dev, NULL);
+       return 0;
+}
+#endif
+
 int
 wl_format_ssid(char* ssid_buf, uint8* ssid, int ssid_len)
 {
@@ -868,7 +1122,7 @@ wl_iw_get_link_speed(
        char *p = extra;
        static int link_speed;
 
-       
+       net_os_wake_lock(dev);
        if (g_onoff == G_WLAN_SET_ON) {
                error = dev_wlc_ioctl(dev, WLC_GET_RATE, &link_speed, sizeof(link_speed));
                link_speed *= 500000;
@@ -878,12 +1132,13 @@ wl_iw_get_link_speed(
 
        wrqu->data.length = p - extra + 1;
 
+       net_os_wake_unlock(dev);
        return error;
 }
 
 
 static int
-wl_iw_get_band(
+wl_iw_get_dtim_skip(
        struct net_device *dev,
        struct iw_request_info *info,
        union iwreq_data *wrqu,
@@ -892,21 +1147,32 @@ wl_iw_get_band(
 {
        int error = -1;
        char *p = extra;
-       static int band;
+       char iovbuf[32];
 
+       net_os_wake_lock(dev);
        if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band));
 
-               p += snprintf(p, MAX_WX_STRING, "Band %d", band);
+                       memset(iovbuf, 0, sizeof(iovbuf));
+                       strcpy(iovbuf, "bcn_li_dtim");
 
-               wrqu->data.length = p - extra + 1;
+                       if ((error = dev_wlc_ioctl(dev, WLC_GET_VAR,
+                               &iovbuf, sizeof(iovbuf))) >= 0) {
+
+                               p += snprintf(p, MAX_WX_STRING, "Dtim_skip %d", iovbuf[0]);
+                               WL_TRACE(("%s: get dtim_skip = %d\n", __FUNCTION__, iovbuf[0]));
+                               wrqu->data.length = p - extra + 1;
+                       }
+                       else
+                               WL_ERROR(("%s: get dtim_skip failed code %d\n", \
+                                       __FUNCTION__, error));
        }
+       net_os_wake_unlock(dev);
        return error;
 }
 
 
 static int
-wl_iw_set_band(
+wl_iw_set_dtim_skip(
        struct net_device *dev,
        struct iw_request_info *info,
        union iwreq_data *wrqu,
@@ -915,86 +1181,358 @@ wl_iw_set_band(
 {
        int error = -1;
        char *p = extra;
-       char band;
+       int bcn_li_dtim;
+       char iovbuf[32];
 
+       net_os_wake_lock(dev);
        if (g_onoff == G_WLAN_SET_ON) {
 
-               band = *(extra + strlen(BAND_SET_CMD) + 1) - '0';
+               bcn_li_dtim = htod32((uint)*(extra + strlen(DTIM_SKIP_SET_CMD) + 1) - '0');
 
-               if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
+               if ((bcn_li_dtim >= 0) || ((bcn_li_dtim <= 5))) {
 
-                       
-                       if ((error = dev_wlc_ioctl(dev, WLC_SET_BAND,
-                               &band, sizeof(band))) >= 0) {
+                       memset(iovbuf, 0, sizeof(iovbuf));
+                       bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
+                               4, iovbuf, sizeof(iovbuf));
+
+                       if ((error = dev_wlc_ioctl(dev, WLC_SET_VAR,
+                               &iovbuf, sizeof(iovbuf))) >= 0) {
                                p += snprintf(p, MAX_WX_STRING, "OK");
-                               WL_TRACE(("%s: set band %d OK\n", __FUNCTION__, band));
+
+                               net_os_set_dtim_skip(dev, bcn_li_dtim);
+
+                               WL_TRACE(("%s: set dtim_skip %d OK\n", __FUNCTION__, \
+                                       bcn_li_dtim));
                                goto exit;
                        }
-                       else  WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \
-                                       band, error));
+                       else  WL_ERROR(("%s: set dtim_skip %d failed code %d\n", \
+                               __FUNCTION__, bcn_li_dtim, error));
                }
-               else  WL_ERROR(("%s Incorrect band setting, ignored\n", __FUNCTION__));
+               else  WL_ERROR(("%s Incorrect dtim_skip setting %d, ignored\n", \
+                       __FUNCTION__, bcn_li_dtim));
        }
 
        p += snprintf(p, MAX_WX_STRING, "FAIL");
 
 exit:
        wrqu->data.length = p - extra + 1;
+       net_os_wake_unlock(dev);
        return error;
 }
 
 
 static int
-wl_iw_get_rssi(
+wl_iw_get_band(
        struct net_device *dev,
        struct iw_request_info *info,
        union iwreq_data *wrqu,
        char *extra
 )
 {
-       static int rssi = 0;
-       static wlc_ssid_t ssid = {0};
-       int error = 0;
+       int error = -1;
        char *p = extra;
-       static char ssidbuf[SSID_FMT_BUF_LEN];
-       scb_val_t scb_val;
+       static int band;
 
-       bzero(&scb_val, sizeof(scb_val_t));
+       net_os_wake_lock(dev);
 
        if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
-               rssi = dtoh32(scb_val.val);
+               error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band));
 
-               error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
+               p += snprintf(p, MAX_WX_STRING, "Band %d", band);
 
-               ssid.SSID_len = dtoh32(ssid.SSID_len);
+               wrqu->data.length = p - extra + 1;
        }
 
-       wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
-       p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi);
-       wrqu->data.length = p - extra + 1;
-
+       net_os_wake_unlock(dev);
        return error;
 }
 
-int
-wl_iw_send_priv_event(
+
+static int
+wl_iw_set_band(
        struct net_device *dev,
-       char *flag
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
 )
 {
-       union iwreq_data wrqu;
-       char extra[IW_CUSTOM_MAX + 1];
-       int cmd;
+       int error = -1;
+       char *p = extra;
+       uint band;
 
-       cmd = IWEVCUSTOM;
-       memset(&wrqu, 0, sizeof(wrqu));
-       if (strlen(flag) > sizeof(extra))
+       net_os_wake_lock(dev);
+
+       if (g_onoff == G_WLAN_SET_ON) {
+
+               band = htod32((uint)*(extra + strlen(BAND_SET_CMD) + 1) - '0');
+
+               if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
+
+                       if ((error = dev_wlc_ioctl(dev, WLC_SET_BAND,
+                               &band, sizeof(band))) >= 0) {
+                               p += snprintf(p, MAX_WX_STRING, "OK");
+                               WL_TRACE(("%s: set band %d OK\n", __FUNCTION__, band));
+                               goto exit;
+                       }
+                       else WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \
+                                       band, error));
+               }
+               else WL_ERROR(("%s Incorrect band setting %d, ignored\n", __FUNCTION__, band));
+       }
+
+       p += snprintf(p, MAX_WX_STRING, "FAIL");
+
+exit:
+       wrqu->data.length = p - extra + 1;
+       net_os_wake_unlock(dev);
+       return error;
+}
+
+#ifdef PNO_SUPPORT
+
+static int
+wl_iw_set_pno_reset(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       int error = -1;
+       char *p = extra;
+
+       net_os_wake_lock(dev);
+       if ((g_onoff == G_WLAN_SET_ON) && (dev != NULL)) {
+
+               if ((error = dhd_dev_pno_reset(dev)) >= 0) {
+                               p += snprintf(p, MAX_WX_STRING, "OK");
+                               WL_TRACE(("%s: set OK\n", __FUNCTION__));
+                               goto exit;
+               }
+               else  WL_ERROR(("%s: failed code %d\n", __FUNCTION__, error));
+       }
+
+       p += snprintf(p, MAX_WX_STRING, "FAIL");
+
+exit:
+       wrqu->data.length = p - extra + 1;
+       net_os_wake_unlock(dev);
+       return error;
+}
+
+
+
+static int
+wl_iw_set_pno_enable(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       int error = -1;
+       char *p = extra;
+       int pfn_enabled;
+
+       net_os_wake_lock(dev);
+       pfn_enabled = htod32((uint)*(extra + strlen(PNOENABLE_SET_CMD) + 1) - '0');
+
+       if ((g_onoff == G_WLAN_SET_ON) && (dev != NULL)) {
+
+               if ((error = dhd_dev_pno_enable(dev, pfn_enabled)) >= 0) {
+                               p += snprintf(p, MAX_WX_STRING, "OK");
+                               WL_TRACE(("%s: set OK\n", __FUNCTION__));
+                               goto exit;
+               }
+               else  WL_ERROR(("%s: failed code %d\n", __FUNCTION__, error));
+       }
+
+       p += snprintf(p, MAX_WX_STRING, "FAIL");
+
+exit:
+       wrqu->data.length = p - extra + 1;
+       net_os_wake_unlock(dev);
+       return error;
+}
+
+
+
+static int
+wl_iw_set_pno_set(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       int res = -1;
+       wlc_ssid_t ssids_local[MAX_PFN_LIST_COUNT];
+       int nssid = 0;
+       cmd_tlv_t *cmd_tlv_temp;
+       char *str_ptr;
+       char *str_ptr_end;
+       int tlv_size_left;
+       int pno_time;
+
+#ifdef PNO_SET_DEBUG
+       int i;
+       char pno_in_example[] = {'P', 'N', 'O', 'S', 'E', 'T', 'U', 'P', ' ', \
+                                                       'S', '1', '2', '0',
+                                                       'S',
+                                                       0x04,
+                                                       'B', 'R', 'C', 'M',
+                                                       'S',
+                                                       0x04,
+                                                       'G', 'O', 'O', 'G',
+                                                       'T',
+                                                       '1','E',
+                                                       0x00
+                                                       };
+#endif
+
+       net_os_wake_lock(dev);
+       WL_ERROR(("\n### %s: info->cmd:%x, info->flags:%x, u.data=0x%p, u.len=%d\n",
+               __FUNCTION__, info->cmd, info->flags,
+               wrqu->data.pointer, wrqu->data.length));
+
+       if (g_onoff == G_WLAN_SET_OFF) {
+               WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
+               goto exit_proc;
+       }
+
+       if (wrqu->data.length < (strlen(PNOSETUP_SET_CMD) + sizeof(cmd_tlv_t))) {
+               WL_ERROR(("%s aggument=%d  less %d\n", __FUNCTION__, \
+                       wrqu->data.length, strlen(PNOSETUP_SET_CMD) + sizeof(cmd_tlv_t)));
+               goto exit_proc;
+       }
+
+#ifdef PNO_SET_DEBUG
+       if (!(extra = kmalloc(sizeof(pno_in_example) +100, GFP_KERNEL))) {
+               res = -ENOMEM;
+               goto exit_proc;
+       }
+       memcpy(extra, pno_in_example, sizeof(pno_in_example));
+       wrqu->data.length = sizeof(pno_in_example);
+       for (i = 0; i < wrqu->data.length; i++)
+               printf("%02X ", extra[i]);
+       printf("\n");
+#endif
+
+       str_ptr = extra;
+#ifdef PNO_SET_DEBUG
+       str_ptr +=  strlen("PNOSETUP ");
+       tlv_size_left = wrqu->data.length - strlen("PNOSETUP ");
+#else
+       str_ptr +=  strlen(PNOSETUP_SET_CMD);
+       tlv_size_left = wrqu->data.length - strlen(PNOSETUP_SET_CMD);
+#endif
+
+       cmd_tlv_temp = (cmd_tlv_t *)str_ptr;
+       memset(ssids_local, 0, sizeof(ssids_local));
+
+       if ((cmd_tlv_temp->prefix == PNO_TLV_PREFIX) && \
+               (cmd_tlv_temp->version == PNO_TLV_VERSION) && \
+               (cmd_tlv_temp->subver == PNO_TLV_SUBVERSION))
+       {
+               str_ptr += sizeof(cmd_tlv_t);
+               tlv_size_left  -= sizeof(cmd_tlv_t);
+
+               if ((nssid = wl_iw_parse_ssid_list_tlv(&str_ptr, ssids_local, \
+                               MAX_PFN_LIST_COUNT, &tlv_size_left)) <= 0) {
+                       WL_ERROR(("SSID is not presented or corrupted ret=%d\n", nssid));
+                       goto exit_proc;
+               }
+               else {
+                       if ((str_ptr[0] != PNO_TLV_TYPE_TIME) || (tlv_size_left <= 1)) {
+                               WL_ERROR(("%s scan duration corrupted field size %d\n", \
+                                               __FUNCTION__, tlv_size_left));
+                               goto exit_proc;
+                       }
+                       str_ptr++;
+                       pno_time = simple_strtoul(str_ptr, &str_ptr_end, 16);
+                       WL_ERROR((" got %d bytes left pno_time %d or %#x\n", \
+                                       tlv_size_left, pno_time, pno_time));
+               }
+       }
+       else {
+               WL_ERROR(("%s get wrong TLV command\n", __FUNCTION__));
+               goto exit_proc;
+       }
+
+       res = dhd_dev_pno_set(dev, ssids_local, nssid, pno_time);
+
+exit_proc:
+       net_os_wake_unlock(dev);
+       return res;
+}
+#endif
+
+static int
+wl_iw_get_rssi(
+       struct net_device *dev,
+       struct iw_request_info *info,
+       union iwreq_data *wrqu,
+       char *extra
+)
+{
+       static int rssi = 0;
+       static wlc_ssid_t ssid = {0};
+       int error = 0;
+       char *p = extra;
+       static char ssidbuf[SSID_FMT_BUF_LEN];
+       scb_val_t scb_val;
+
+       net_os_wake_lock(dev);
+
+       bzero(&scb_val, sizeof(scb_val_t));
+
+       if (g_onoff == G_WLAN_SET_ON) {
+               error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
+               if (error) {
+                       WL_ERROR(("%s: Fails %d\n", __FUNCTION__, error));
+               } else {
+                       rssi = dtoh32(scb_val.val);
+
+                       error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
+                       if (!error) {
+                               ssid.SSID_len = dtoh32(ssid.SSID_len);
+                               wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
+                       }
+               }
+       }
+
+       WL_ASSOC(("%s ssid_len:%d, rssi:%d\n", __FUNCTION__, ssid.SSID_len, rssi));
+
+       if (error || (ssid.SSID_len == 0)) {
+               p += snprintf(p, MAX_WX_STRING, "FAIL");
+       } else {
+               p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi);
+       }
+       wrqu->data.length = p - extra + 1;
+
+       net_os_wake_unlock(dev);
+       return error;
+}
+
+int
+wl_iw_send_priv_event(
+       struct net_device *dev,
+       char *flag
+)
+{
+       union iwreq_data wrqu;
+       char extra[IW_CUSTOM_MAX + 1];
+       int cmd;
+
+       cmd = IWEVCUSTOM;
+       memset(&wrqu, 0, sizeof(wrqu));
+       if (strlen(flag) > sizeof(extra))
                return -1;
 
        strcpy(extra, flag);
        wrqu.data.length = strlen(extra);
        wireless_send_event(dev, cmd, &wrqu, extra);
+       net_os_wake_lock_timeout_enable(dev);
        WL_TRACE(("Send IWEVCUSTOM Event as %s\n", extra));
 
        return 0;
@@ -1015,30 +1553,37 @@ wl_control_wl_start(struct net_device *dev)
        }
 
        iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK(iw->pub);
+
+       if (!iw) {
+               WL_ERROR(("%s: wl is null\n", __FUNCTION__));
+               return -1;
+       }
+       dhd_os_start_lock(iw->pub);
 
        if (g_onoff == G_WLAN_SET_OFF) {
                dhd_customer_gpio_wlan_ctrl(WLAN_RESET_ON);
-#if 0
+
 #if defined(BCMLXSDMMC)
                sdioh_start(NULL, 0);
 #endif
 
-               dhd_dev_reset(dev, 0);
+               ret = dhd_dev_reset(dev, 0);
 
+               if (ret == BCME_OK) {
 #if defined(BCMLXSDMMC)
-               sdioh_start(NULL, 1);
-#endif
-
-               dhd_dev_init_ioctl(dev);
+                       sdioh_start(NULL, 1);
 #endif
-               g_onoff = G_WLAN_SET_ON;
+                       dhd_dev_init_ioctl(dev);
+                       g_onoff = G_WLAN_SET_ON;
+               }
        }
        WL_TRACE(("Exited %s \n", __FUNCTION__));
 
-       MUTEX_UNLOCK(iw->pub);
+       dhd_os_start_unlock(iw->pub);
        return ret;
 }
+
+
 static int
 wl_iw_control_wl_off(
        struct net_device *dev,
@@ -1056,46 +1601,51 @@ wl_iw_control_wl_off(
        }
 
        iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK(iw->pub);
+       if (!iw) {
+               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
+               return -1;
+       }
+       dhd_os_start_lock(iw->pub);
 
 #ifdef SOFTAP
        ap_cfg_running = FALSE;
-#endif 
+#endif
 
        if (g_onoff == G_WLAN_SET_ON) {
                g_onoff = G_WLAN_SET_OFF;
-
 #if defined(WL_IW_USE_ISCAN)
                g_iscan->iscan_state = ISCAN_STATE_IDLE;
-#endif 
-#if 0
-               dhd_dev_reset(dev, 1);
 #endif
+
+               dhd_dev_reset(dev, 1);
+
 #if defined(WL_IW_USE_ISCAN)
 #if !defined(CSCAN)
-               
                wl_iw_free_ss_cache();
                wl_iw_run_ss_cache_timer(0);
-               
+
                g_ss_cache_ctrl.m_link_down = 1;
-#endif 
+#endif
                memset(g_scan, 0, G_SCAN_RESULTS);
                g_scan_specified_ssid = 0;
-               
+#if defined(CONFIG_FIRST_SCAN)
                g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
-#endif 
-#if 0
+               g_first_counter_scans = 0;
+#endif
+#endif
+
 #if defined(BCMLXSDMMC)
                sdioh_stop(NULL);
 #endif
-#endif
+
+               net_os_set_dtim_skip(dev, 0);
+
                dhd_customer_gpio_wlan_ctrl(WLAN_RESET_OFF);
 
                wl_iw_send_priv_event(dev, "STOP");
-
        }
 
-       MUTEX_UNLOCK(iw->pub);
+       dhd_os_start_unlock(iw->pub);
 
        WL_TRACE(("Exited %s\n", __FUNCTION__));
 
@@ -1112,11 +1662,18 @@ wl_iw_control_wl_on(
 
        WL_TRACE(("Enter %s \n", __FUNCTION__));
 
-       ret = wl_control_wl_start(dev);
+       if ((ret = wl_control_wl_start(dev)) != BCME_OK) {
+               WL_ERROR(("%s failed first attemp\n", __FUNCTION__));
+               dhd_customer_gpio_wlan_ctrl(WLAN_RESET_OFF);
+               if ((ret = wl_control_wl_start(dev)) != BCME_OK) {
+                       WL_ERROR(("%s failed second attemp\n", __FUNCTION__));
+                       net_os_send_hang_message(dev);
+                       return ret;
+               }
+       }
 
        wl_iw_send_priv_event(dev, "START");
 
-#if !defined(CSCAN)
 #ifdef SOFTAP
        if (!ap_fw_loaded) {
                wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
@@ -1124,7 +1681,6 @@ wl_iw_control_wl_on(
 #else
        wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
 #endif
-#endif 
 
        WL_TRACE(("Exited %s \n", __FUNCTION__));
 
@@ -1133,10 +1689,18 @@ wl_iw_control_wl_on(
 
 #ifdef SOFTAP
 static struct ap_profile my_ap;
-static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap); 
+static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap);
 static int get_assoc_sta_list(struct net_device *dev, char *buf, int len);
-static int set_ap_mac_list(struct net_device *dev, char *buf);
-#endif /* SOFTAP */
+static int set_ap_mac_list(struct net_device *dev, void *buf);
+
+#define PTYPE_STRING   0
+#define PTYPE_INTDEC   1
+#define PTYPE_INTHEX   2
+#define PTYPE_STR_HEX  3
+int get_parmeter_from_string(
+       char **str_ptr, const char *token, int param_type, void  *dst, int param_max_len);
+
+#endif
 
 int hex2num(char c)
 {
@@ -1182,94 +1746,6 @@ int hstr_2_buf(const char *txt, u8 *buf, int len)
        return 0;
 }
 
-
-
-#if defined(SOFTAP) || defined(CSCAN)
-
-/* parameter type */
-#define PTYPE_STRING   0
-#define PTYPE_INTDEC   1   
-#define PTYPE_INTHEX   2
-#define PTYPE_STR_HEX  3  
-
-int get_parmeter_from_string(
-                       char **str_ptr, const char *token,
-                       int param_type, void  *dst, int param_max_len)
-{
-       char int_str[7] = "0";
-       int parm_str_len;
-       char  *param_str_begin;
-       char  *param_str_end;
-       char  *orig_str = *str_ptr;
-
-       if ((*str_ptr) && !strncmp(*str_ptr, token, strlen(token))) {
-
-               strsep(str_ptr, "=,"); 
-               param_str_begin = *str_ptr;
-               strsep(str_ptr, "=,"); 
-
-               if (*str_ptr == NULL) {
-                       
-                       parm_str_len = strlen(param_str_begin);
-               } else {
-                       param_str_end = *str_ptr-1;  
-                       parm_str_len = param_str_end - param_str_begin;
-               }
-
-               WL_TRACE((" 'token:%s', len:%d, ", token, parm_str_len));
-
-               if (parm_str_len > param_max_len) {
-                       WL_ERROR((" WARNING: extracted param len:%d is > MAX:%d\n",
-                               parm_str_len, param_max_len));
-
-                       parm_str_len = param_max_len;
-               }
-
-               switch (param_type) {
-
-                       case PTYPE_INTDEC: {
-                       
-                               int *pdst_int = dst;
-                               char *eptr;
-                               if (parm_str_len > sizeof(int_str))
-                                        parm_str_len = sizeof(int_str);
-
-                               memcpy(int_str, param_str_begin, parm_str_len);
-
-                               *pdst_int = simple_strtoul(int_str, &eptr, 10);
-
-                               WL_TRACE((" written as integer:%d\n",  *pdst_int));
-                       }
-                       break;
-                       case PTYPE_STR_HEX: {
-                               u8 *buf = dst;
-                               
-                               param_max_len = param_max_len >> 1;  
-                               hstr_2_buf(param_str_begin, buf, param_max_len);
-                               print_buf(buf, param_max_len, 0);
-                       }
-                       break;
-                       default:
-                               
-                               memcpy(dst, param_str_begin, parm_str_len);
-                               *((char *)dst + parm_str_len) = 0; 
-                               WL_ERROR((" written as a string:%s\n", (char *)dst));
-                       break;
-
-               }
-
-               return 0;
-       } else {
-               WL_ERROR(("\n %s: ERROR: can't find token:%s in str:%s \n",
-                       __FUNCTION__, token, orig_str));
-
-        return -1;
-       }
-}
-
-#endif 
-
-
 #ifdef SOFTAP
 int init_ap_profile_from_string(char *param_str, struct ap_profile *ap_cfg)
 {
@@ -1280,18 +1756,15 @@ int init_ap_profile_from_string(char *param_str, struct ap_profile *ap_cfg)
        memset(sub_cmd, 0, sizeof(sub_cmd));
        memset(ap_cfg, 0, sizeof(struct ap_profile));
 
-       
        if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=",
                PTYPE_STRING, sub_cmd, SSID_LEN) != 0) {
-        return -1;
+               return -1;
        }
        if (strncmp(sub_cmd, "AP_CFG", 6)) {
-          WL_ERROR(("ERROR: sub_cmd:%s != 'AP_CFG'!\n", sub_cmd));
+               WL_ERROR(("ERROR: sub_cmd:%s != 'AP_CFG'!\n", sub_cmd));
                return -1;
        }
 
-       
-       
        ret = get_parmeter_from_string(&str_ptr, "SSID=", PTYPE_STRING, ap_cfg->ssid, SSID_LEN);
 
        ret |= get_parmeter_from_string(&str_ptr, "SEC=", PTYPE_STRING,  ap_cfg->sec, SEC_LEN);
@@ -1300,31 +1773,34 @@ int init_ap_profile_from_string(char *param_str, struct ap_profile *ap_cfg)
 
        ret |= get_parmeter_from_string(&str_ptr, "CHANNEL=", PTYPE_INTDEC, &ap_cfg->channel, 5);
 
-       ret |= get_parmeter_from_string(&str_ptr, "PREAMBLE=", PTYPE_INTDEC, &ap_cfg->preamble, 5);
+       get_parmeter_from_string(&str_ptr, "PREAMBLE=", PTYPE_INTDEC, &ap_cfg->preamble, 5);
+
+       get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC,  &ap_cfg->max_scb, 5);
 
-       ret |= get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC,  &ap_cfg->max_scb, 5);
+       get_parmeter_from_string(&str_ptr, "HIDDEN=", PTYPE_INTDEC, &ap_cfg->closednet, 5);
+
+       get_parmeter_from_string(&str_ptr, "COUNTRY=", PTYPE_STRING, &ap_cfg->country_code, 3);
 
        return ret;
 }
-#endif 
-
+#endif
 
 
 #ifdef SOFTAP
 static int iwpriv_set_ap_config(struct net_device *dev,
-            struct iw_request_info *info,
-            union iwreq_data *wrqu,
-            char *ext)
+               struct iw_request_info *info,
+               union iwreq_data *wrqu,
+               char *ext)
 {
        int res = 0;
        char  *extra = NULL;
        struct ap_profile *ap_cfg = &my_ap;
 
-       WL_TRACE(("> Got IWPRIV SET_AP IOCTL: info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
+       WL_TRACE(("%s: info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
+               __FUNCTION__,
                info->cmd, info->flags,
                wrqu->data.pointer, wrqu->data.length));
 
-
        if (wrqu->data.length != 0) {
 
                char *str_ptr;
@@ -1342,8 +1818,6 @@ static int iwpriv_set_ap_config(struct net_device *dev,
 
                memset(ap_cfg, 0, sizeof(struct ap_profile));
 
-               
-
                str_ptr = extra;
 
                if ((res = init_ap_profile_from_string(extra, ap_cfg)) < 0) {
@@ -1353,9 +1827,8 @@ static int iwpriv_set_ap_config(struct net_device *dev,
                }
 
        } else {
-        
-         WL_ERROR(("IWPRIV argument len = 0 \n"));
-         return -1;
+               WL_ERROR(("IWPRIV argument len = 0 \n"));
+               return -1;
        }
 
        if ((res = set_ap_cfg(dev, ap_cfg)) < 0)
@@ -1365,88 +1838,120 @@ static int iwpriv_set_ap_config(struct net_device *dev,
 
        return res;
 }
-#endif 
-
+#endif
 
 
 #ifdef SOFTAP
 static int iwpriv_get_assoc_list(struct net_device *dev,
-        struct iw_request_info *info,
-        union iwreq_data *p_iwrq,
-        char *extra)
+               struct iw_request_info *info,
+               union iwreq_data *p_iwrq,
+               char *extra)
 {
        int i, ret = 0;
        char mac_buf[256];
        struct maclist *sta_maclist = (struct maclist *)mac_buf;
 
-       char mac_lst[256];
+       char mac_lst[384];
        char *p_mac_str;
+       char *p_mac_str_end;
+
+       if ((!dev) || (!extra)) {
+               return -EINVAL;
+       }
+
+       net_os_wake_lock(dev);
 
        WL_TRACE(("\n %s: IWPRIV IOCTL: cmd:%hx, flags:%hx, extra:%p, iwp.len:%d, \
                iwp.len:%p, iwp.flags:%x  \n", __FUNCTION__, info->cmd, info->flags, \
                extra, p_iwrq->data.length, p_iwrq->data.pointer, p_iwrq->data.flags));
 
-       WL_SOFTAP(("extra:%s\n", extra));
-       print_buf((u8 *)p_iwrq, 16, 0);
-
        memset(sta_maclist, 0, sizeof(mac_buf));
 
        sta_maclist->count = 8;
 
-       WL_TRACE((" net device:%s, buf_sz:%d\n", dev->name, sizeof(mac_buf)));
-       get_assoc_sta_list(dev, mac_buf, 256);
-       WL_TRACE((" got %d stations\n", sta_maclist->count));
+       WL_SOFTAP(("%s: net device:%s, buf_sz:%d\n",
+               __FUNCTION__, dev->name, sizeof(mac_buf)));
+
+       if ((ret = get_assoc_sta_list(dev, mac_buf, sizeof(mac_buf))) < 0) {
+               WL_ERROR(("%s: sta list ioctl error:%d\n",
+                       __FUNCTION__, ret));
+               goto func_exit;
+       }
+
+       WL_SOFTAP(("%s: got %d stations\n", __FUNCTION__,
+               sta_maclist->count));
 
-       
        memset(mac_lst, 0, sizeof(mac_lst));
        p_mac_str = mac_lst;
+       p_mac_str_end = &mac_lst[sizeof(mac_lst)-1];
 
        for (i = 0; i < 8; i++) {
-               struct ether_addr * id = &sta_maclist->ea[i];
+               struct ether_addr *id = &sta_maclist->ea[i];
+               if (!ETHER_ISNULLADDR(id->octet)) {
+                       scb_val_t scb_val;
+                       int rssi = 0;
 
-               WL_SOFTAP(("dhd_drv>> sta_mac[%d] :", i));
-               print_buf((unsigned char *)&sta_maclist->ea[i], 6, 0);
+                       bzero(&scb_val, sizeof(scb_val_t));
 
-               
-               p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
-                       "Mac[%d]=%02X:%02X:%02X:%02X:%02X:%02X\n", i,
+                       if ((p_mac_str_end - p_mac_str) <= 36) {
+                               WL_ERROR(("%s: mac list buf is < 36 for item[%i] item\n",
+                                       __FUNCTION__, i));
+                               break;
+                       }
+
+                       p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
+                       "\nMac[%d]=%02X:%02X:%02X:%02X:%02X:%02X,", i,
                        id->octet[0], id->octet[1], id->octet[2],
                        id->octet[3], id->octet[4], id->octet[5]);
 
+                       bcopy(id->octet, &scb_val.ea, 6);
+                       ret = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
+                       if (ret  < 0) {
+                               snprintf(p_mac_str, MAX_WX_STRING, "RSSI:ERR");
+                               WL_ERROR(("%s: RSSI ioctl error:%d\n",
+                                       __FUNCTION__, ret));
+                               break;
+                       }
+
+                       rssi = dtoh32(scb_val.val);
+                       p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
+                       "RSSI:%d", rssi);
+               }
        }
 
-       p_iwrq->data.length = strlen(mac_lst);
+       p_iwrq->data.length = strlen(mac_lst) + 1;
 
-       WL_TRACE(("u.pointer:%p\n", p_iwrq->data.pointer));
-       WL_TRACE(("resulting str:\n%s \n len:%d\n\n", mac_lst, p_iwrq->data.length));
+       WL_SOFTAP(("%s: data to user:\n%s\n usr_ptr:%p\n", __FUNCTION__,
+               mac_lst, p_iwrq->data.pointer));
 
        if (p_iwrq->data.length) {
-               if (copy_to_user(p_iwrq->data.pointer, mac_lst, p_iwrq->data.length)) {
-                       WL_ERROR(("%s: Can't copy to user\n", __FUNCTION__));
-                       return -EFAULT;
-               }
+               bcopy(mac_lst, extra, p_iwrq->data.length);
        }
 
-       WL_ERROR(("Exited %s \n", __FUNCTION__));
+func_exit:
+       net_os_wake_unlock(dev);
+
+       WL_TRACE(("Exited %s \n", __FUNCTION__));
        return ret;
 }
-#endif 
+#endif
 
 
 #ifdef SOFTAP
+#define MAC_FILT_MAX 8
 static int iwpriv_set_mac_filters(struct net_device *dev,
-        struct iw_request_info *info,
-        union iwreq_data *wrqu,
-        char *ext)
+               struct iw_request_info *info,
+               union iwreq_data *wrqu,
+               char *ext)
 {
-
        int i, ret = -1;
        char  * extra = NULL;
-       u8  macfilt[8][6];
-       int mac_cnt = 0; 
-       char sub_cmd[16];
+       int mac_cnt = 0;
+       int mac_mode = 0;
+       struct ether_addr *p_ea;
+       struct mac_list_set mflist_set;
 
-       WL_TRACE((">>> Got IWPRIV SET_MAC_FILTER IOCTL:  info->cmd:%x, \
+       WL_SOFTAP((">>> Got IWPRIV SET_MAC_FILTER IOCTL:  info->cmd:%x, \
                        info->flags:%x, u.data:%p, u.len:%d\n",
                        info->cmd, info->flags,
                        wrqu->data.pointer, wrqu->data.length));
@@ -1466,27 +1971,21 @@ static int iwpriv_set_mac_filters(struct net_device *dev,
                extra[wrqu->data.length] = 0;
                WL_SOFTAP((" Got parameter string in iw_point:\n %s \n", extra));
 
-               memset(macfilt, 0, sizeof(macfilt));
-               memset(sub_cmd, 0, sizeof(sub_cmd));
+               memset(&mflist_set, 0, sizeof(mflist_set));
 
-               
                str_ptr = extra;
 
-               
-          if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=", PTYPE_STRING, sub_cmd, 15) != 0) {
-                goto exit_proc;
-          }
-
-#define MAC_FILT_MAX 8
-          
-               if (strncmp(sub_cmd, "MAC_FLT_W", strlen("MAC_FLT_W"))) {
-                  WL_ERROR(("ERROR: sub_cmd:%s != 'MAC_FLT_W'!\n", sub_cmd));
+               if (get_parmeter_from_string(&str_ptr, "MAC_MODE=",
+                       PTYPE_INTDEC, &mac_mode, 4) != 0) {
+                       WL_ERROR(("ERROR: 'MAC_MODE=' token is missing\n"));
                        goto exit_proc;
                }
 
+               p_ea = &mflist_set.mac_list.ea[0];
+
                if (get_parmeter_from_string(&str_ptr, "MAC_CNT=",
                        PTYPE_INTDEC, &mac_cnt, 4) != 0) {
-                       WL_ERROR(("ERROR: MAC_CNT param is missing \n"));
+                       WL_ERROR(("ERROR: 'MAC_CNT=' token param is missing \n"));
                        goto exit_proc;
                }
 
@@ -1495,36 +1994,75 @@ static int iwpriv_set_mac_filters(struct net_device *dev,
                        goto exit_proc;
                }
 
-               for (i=0; i< mac_cnt; i++)      
-               if (get_parmeter_from_string(&str_ptr, "MAC=",
-                       PTYPE_STR_HEX, macfilt[i], 12) != 0) {
-                       WL_ERROR(("ERROR: MAC_filter[%d] is missing !\n", i));
-                       goto exit_proc;
-               }
+               for (i=0; i < mac_cnt; i++)
+                       if (get_parmeter_from_string(&str_ptr, "MAC=",
+                               PTYPE_STR_HEX, &p_ea[i], 12) != 0) {
+                               WL_ERROR(("ERROR: MAC_filter[%d] is missing !\n", i));
+                               goto exit_proc;
+                       }
 
+               WL_SOFTAP(("MAC_MODE=:%d, MAC_CNT=%d, MACs:..\n", mac_mode, mac_cnt));
                for (i = 0; i < mac_cnt; i++) {
                   WL_SOFTAP(("mac_filt[%d]:", i));
-                  print_buf(macfilt[i], 6, 0);
+                  print_buf(&p_ea[i], 6, 0);
                }
 
-               
+               mflist_set.mode = mac_mode;
+               mflist_set.mac_list.count = mac_cnt;
+               set_ap_mac_list(dev, &mflist_set);
+
                wrqu->data.pointer = NULL;
                wrqu->data.length = 0;
                ret = 0;
 
        } else {
-        
-         WL_ERROR(("IWPRIV argument len is 0\n"));
-         return -1;
+               WL_ERROR(("IWPRIV argument len is 0\n"));
+               return -1;
        }
 
        exit_proc:
        kfree(extra);
        return ret;
 }
-#endif 
+#endif
+
+
+#ifdef SOFTAP
+static int iwpriv_set_ap_sta_disassoc(struct net_device *dev,
+        struct iw_request_info *info,
+        union iwreq_data *wrqu,
+        char *ext)
+{
+       int res = 0;
+       char sta_mac[6] = {0, 0, 0, 0, 0, 0};
+       char cmd_buf[256];
+       char *str_ptr = cmd_buf;
+
+       WL_SOFTAP((">>%s called\n args: info->cmd:%x,"
+               " info->flags:%x, u.data.p:%p, u.data.len:%d\n",
+               __FUNCTION__, info->cmd, info->flags,
+               wrqu->data.pointer, wrqu->data.length));
+
+       if (wrqu->data.length != 0) {
+
+               if (copy_from_user(cmd_buf, wrqu->data.pointer, wrqu->data.length)) {
+                       return -EFAULT;
+               }
+
+               if (get_parmeter_from_string(&str_ptr,
+                       "MAC=", PTYPE_STR_HEX, sta_mac, 12) == 0) {
+                       res = wl_iw_softap_deassoc_stations(dev, sta_mac);
+               } else  {
+                       WL_ERROR(("ERROR: STA_MAC= token not found\n"));
+               }
+       }
+
+       return res;
+}
+#endif
+
+#endif
 
-#endif 
 
 #if WIRELESS_EXT < 13
 struct iw_request_info
@@ -1534,9 +2072,9 @@ struct iw_request_info
 };
 
 typedef int (*iw_handler)(struct net_device *dev,
-                struct iw_request_info *info,
-                void *wrqu,
-                char *extra);
+               struct iw_request_info *info,
+               void *wrqu,
+               char *extra);
 #endif 
 
 static int
@@ -1546,7 +2084,7 @@ wl_iw_config_commit(
        void *zwrq,
        char *extra
 )
-{      
+{
        wlc_ssid_t ssid;
        int error;
        struct sockaddr bssid;
@@ -1596,7 +2134,7 @@ wl_iw_set_freq(
        int error, chan;
        uint sf = 0;
 
-       WL_TRACE(("%s %s: SIOCSIWFREQ : e=%d m=%d\n", __func__, dev->name, fwrq->e, fwrq->m));
+       WL_TRACE(("%s %s: SIOCSIWFREQ\n", __FUNCTION__, dev->name));
 
 #if defined(SOFTAP)
        if (ap_cfg_running) {
@@ -1606,33 +2144,32 @@ wl_iw_set_freq(
 #endif
 
        
-       if (fwrq->e == 0 && fwrq->m < MAXCHANNEL) 
-       {
+       if (fwrq->e == 0 && fwrq->m < MAXCHANNEL) {
                chan = fwrq->m;
        }
-       else 
-       {
-               if (fwrq->e >= 6) 
-               {
+
+       
+       else {
+               
+               if (fwrq->e >= 6) {
                        fwrq->e -= 6;
                        while (fwrq->e--)
                                fwrq->m *= 10;
-               } 
-               else if (fwrq->e < 6) 
-               {
+               } else if (fwrq->e < 6) {
                        while (fwrq->e++ < 6)
                                fwrq->m /= 10;
                }
        
-               if (fwrq->m > 4000 && fwrq->m < 5000)
-                       sf = WF_CHAN_FACTOR_4_G; 
+       if (fwrq->m > 4000 && fwrq->m < 5000)
+               sf = WF_CHAN_FACTOR_4_G; 
 
                chan = wf_mhz2channel(fwrq->m, sf);
        }
-       chan = htod32(chan);    
+       chan = htod32(chan);
        if ((error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan))))
                return error;
 
+       g_wl_iw_params.target_channel = chan;
        
        return -EINPROGRESS;
 }
@@ -1653,7 +2190,6 @@ wl_iw_get_freq(
        if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
                return error;
 
-       
        fwrq->m = dtoh32(ci.hw_channel);
        fwrq->e = dtoh32(0);
        return 0;
@@ -1692,80 +2228,30 @@ wl_iw_set_mode(
                return error;
 
        
-       return -EINPROGRESS;
-}
-
-static int
-wl_iw_get_mode(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       __u32 *uwrq,
-       char *extra
-)
-{
-       int error, infra = 0, ap = 0;
-
-       WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
-           (error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
-               return error;
-
-       infra = dtoh32(infra);
-       ap = dtoh32(ap);
-       *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
-
-       return 0;
-}
-
-static int
-wl_iw_set_sens(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       __u32 *uwrq,
-       char *extra
-)
-{
-       WL_TRACE(("%s: SIOCSIWSENS\n", dev->name));
-       return 0;
+       return -EINPROGRESS;
 }
 
 static int
-wl_iw_get_sens(
+wl_iw_get_mode(
        struct net_device *dev,
        struct iw_request_info *info,
-       union iwreq_data *wrqu,
+       __u32 *uwrq,
        char *extra
 )
 {
-       static int rssi = 0;
-       static wlc_ssid_t ssid = {0};
-       int error = 0;
-       static char ssidbuf[SSID_FMT_BUF_LEN];
-       scb_val_t scb_val;
+       int error, infra = 0, ap = 0;
 
-       WL_TRACE(("%s: SIOCGIWSENS\n", dev->name));
-       
-       bzero(&scb_val, sizeof(scb_val_t));
-       
-       if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
-               if (error) {
-                       WL_ERROR(("%s: Fails %d\n", __FUNCTION__, error));
-                       return error;
-               }
-               rssi = dtoh32(scb_val.val);
-               
-               error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
-               if (!error) {
-                       ssid.SSID_len = dtoh32(ssid.SSID_len);
-                       wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
-               }
-       }
-       
-       wrqu->sens.value = -rssi;
-    
-       return error;
+       WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
+
+       if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
+           (error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
+               return error;
+
+       infra = dtoh32(infra);
+       ap = dtoh32(ap);
+       *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
+
+       return 0;
 }
 
 static int
@@ -1807,10 +2293,8 @@ wl_iw_get_range(
        dwrq->length = sizeof(struct iw_range);
        memset(range, 0, sizeof(range));
 
-       
        range->min_nwid = range->max_nwid = 0;
 
-       
        list->count = htod32(MAXCHANNEL);
        if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, (MAXCHANNEL+1)*4))) {
                kfree(channels);
@@ -1830,7 +2314,6 @@ wl_iw_get_range(
        }
        range->num_frequency = range->num_channels = i;
 
-       
        range->max_qual.qual = 5;
        
        range->max_qual.level = 0x100 - 200;    
@@ -1848,7 +2331,6 @@ wl_iw_get_range(
        range->avg_qual.noise = 0x100 - 75;     
 #endif 
 
-       
        if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset)))) {
                kfree(channels);
                return error;
@@ -1887,7 +2369,6 @@ wl_iw_get_range(
                }
        }
 
-       
        if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i)))) {
                kfree(channels);
                return error;
@@ -1898,7 +2379,6 @@ wl_iw_get_range(
        else
                range->throughput = 1500000;    
 
-       
        range->min_rts = 0;
        range->max_rts = 2347;
        range->min_frag = 256;
@@ -1915,7 +2395,6 @@ wl_iw_get_range(
 #endif
        range->encoding_size[3] = AES_KEY_SIZE;
 
-       
        range->min_pmp = 0;
        range->max_pmp = 0;
        range->min_pmt = 0;
@@ -1923,7 +2402,6 @@ wl_iw_get_range(
        range->pmp_flags = 0;
        range->pm_capa = 0;
 
-       
        range->num_txpower = 2;
        range->txpower[0] = 1;
        range->txpower[1] = 255;
@@ -1933,7 +2411,6 @@ wl_iw_get_range(
        range->we_version_compiled = WIRELESS_EXT;
        range->we_version_source = 19;
 
-       
        range->retry_capa = IW_RETRY_LIMIT;
        range->retry_flags = IW_RETRY_LIMIT;
        range->r_time_flags = 0;
@@ -1953,9 +2430,8 @@ wl_iw_get_range(
        range->enc_capa |= IW_ENC_CAPA_WPA2;
 #endif
 
-       
        IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
-       
+
        IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
        IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
        IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
@@ -2041,6 +2517,41 @@ wl_iw_get_spy(
        return 0;
 }
 
+
+static int
+wl_iw_ch_to_chanspec(int ch, wl_join_params_t *join_params, int *join_params_size)
+{
+       chanspec_t chanspec = 0;
+
+       if (ch != 0) {
+
+               join_params->params.chanspec_num = 1;
+               join_params->params.chanspec_list[0] = ch;
+
+               if (join_params->params.chanspec_list[0])
+                       chanspec |= WL_CHANSPEC_BAND_2G;
+               else
+                       chanspec |= WL_CHANSPEC_BAND_5G;
+
+               chanspec |= WL_CHANSPEC_BW_20;
+               chanspec |= WL_CHANSPEC_CTL_SB_NONE;
+
+               *join_params_size += WL_ASSOC_PARAMS_FIXED_SIZE +
+                       join_params->params.chanspec_num * sizeof(chanspec_t);
+
+               join_params->params.chanspec_list[0]  &= WL_CHANSPEC_CHAN_MASK;
+               join_params->params.chanspec_list[0] |= chanspec;
+               join_params->params.chanspec_list[0] =
+                       htodchanspec(join_params->params.chanspec_list[0]);
+
+               join_params->params.chanspec_num = htod32(join_params->params.chanspec_num);
+
+               WL_TRACE(("%s  join_params->params.chanspec_list[0]= %X\n", \
+                       __FUNCTION__, join_params->params.chanspec_list[0]));
+       }
+       return 1;
+}
+
 static int
 wl_iw_set_wap(
        struct net_device *dev,
@@ -2051,6 +2562,7 @@ wl_iw_set_wap(
 {
        int error = -EINVAL;
        wl_join_params_t join_params;
+       int join_params_size;
 
        WL_TRACE(("%s: SIOCSIWAP\n", dev->name));
 
@@ -2072,16 +2584,26 @@ wl_iw_set_wap(
 
        
        memset(&join_params, 0, sizeof(join_params));
+       join_params_size = sizeof(join_params.ssid);
 
        memcpy(join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
        join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
        memcpy(&join_params.params.bssid, awrq->sa_data, ETHER_ADDR_LEN);
 
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, sizeof(join_params)))) {
-               WL_ERROR(("Invalid ioctl data.\n"));
+       WL_ASSOC(("%s  target_channel=%d\n", __FUNCTION__, g_wl_iw_params.target_channel));
+       wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params, &join_params_size);
+
+       if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size))) {
+               WL_ERROR(("%s Invalid ioctl data=%d\n", __FUNCTION__, error));
                return error;
        }
 
+       if (g_ssid.SSID_len) {
+               WL_ASSOC(("%s: join SSID=%s BSSID="MACSTR" ch=%d\n", __FUNCTION__,  \
+                       g_ssid.SSID, MAC2STR((u8 *)awrq->sa_data), \
+                       g_wl_iw_params.target_channel));
+       }
+
        
        memset(&g_ssid, 0, sizeof(g_ssid));
        return 0;
@@ -2148,6 +2670,7 @@ wl_iw_mlme(
 }
 #endif 
 
+#ifndef WL_IW_USE_ISCAN
 static int
 wl_iw_get_aplist(
        struct net_device *dev,
@@ -2168,7 +2691,6 @@ wl_iw_get_aplist(
        if (!extra)
                return -EINVAL;
 
-       
        list = kmalloc(buflen, GFP_KERNEL);
        if (!list)
                return -ENOMEM;
@@ -2183,7 +2705,7 @@ wl_iw_get_aplist(
        list->version = dtoh32(list->version);
        list->count = dtoh32(list->count);
        if (list->version != WL_BSS_INFO_VERSION) {
-               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
+               WL_ERROR(("%s: list->version %d != WL_BSS_INFO_VERSION\n", \
                         __FUNCTION__, list->version));
                kfree(list);
                return -EINVAL;
@@ -2191,21 +2713,23 @@ wl_iw_get_aplist(
 
        for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
                bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
-               ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
-                       buflen));
 
-               
+               if ((dtoh32(bi->length) > buflen) ||
+                   (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + buflen))) {
+                       WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
+                       kfree(list);
+                       return -E2BIG;
+               }
+
                if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
                        continue;
 
-               
                memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
                addr[dwrq->length].sa_family = ARPHRD_ETHER;
                qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
                qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
                qual[dwrq->length].noise = 0x100 + bi->phy_noise;
 
-               
 #if WIRELESS_EXT > 18
                qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
 #else
@@ -2222,9 +2746,9 @@ wl_iw_get_aplist(
                
                dwrq->flags = 1;
        }
-
        return 0;
 }
+#endif
 
 #ifdef WL_IW_USE_ISCAN
 static int
@@ -2250,7 +2774,8 @@ wl_iw_iscan_get_aplist(
                return -EINVAL;
 
        if ((!iscan) || (iscan->sysioc_pid < 0)) {
-               return wl_iw_get_aplist(dev, info, dwrq, extra);
+               WL_ERROR(("%s error\n", __FUNCTION__));
+               return 0;
        }
 
        buf = iscan->list_hdr;
@@ -2267,21 +2792,22 @@ wl_iw_iscan_get_aplist(
                for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
                        bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length))
                                  : list->bss_info;
-                       ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
-                               WLC_IW_ISCAN_MAXLEN));
 
-                       
+                       if ((dtoh32(bi->length) > WLC_IW_ISCAN_MAXLEN) ||
+                           (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + WLC_IW_ISCAN_MAXLEN))) {
+                               WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
+                               return -E2BIG;
+                       }
+
                        if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
                                continue;
 
-                       
                        memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
                        addr[dwrq->length].sa_family = ARPHRD_ETHER;
                        qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
                        qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
                        qual[dwrq->length].noise = 0x100 + bi->phy_noise;
 
-                       
 #if WIRELESS_EXT > 18
                        qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
 #else
@@ -2297,7 +2823,6 @@ wl_iw_iscan_get_aplist(
                
                dwrq->flags = 1;
        }
-
        return 0;
 }
 
@@ -2314,7 +2839,10 @@ wl_iw_iscan_prep(wl_scan_params_t *params, wlc_ssid_t *ssid)
        params->passive_time = -1;
        params->home_time = -1;
        params->channel_num = 0;
-
+#if defined(CONFIG_FIRST_SCAN)
+       if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
+               params->passive_time = 30;
+#endif
        params->nprobes = htod32(params->nprobes);
        params->active_time = htod32(params->active_time);
        params->passive_time = htod32(params->passive_time);
@@ -2341,9 +2869,11 @@ wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, uint16 action)
        WL_SCAN(("scan_type=%d\n", iscan->iscan_ex_params_p->params.scan_type));
        WL_SCAN(("bss_type=%d\n", iscan->iscan_ex_params_p->params.bss_type));
 
-       
-       (void) dev_iw_iovar_setbuf(iscan->dev, "iscan", iscan->iscan_ex_params_p, \
-               iscan->iscan_ex_param_size, iscan->ioctlbuf, sizeof(iscan->ioctlbuf));
+       if ((err = dev_iw_iovar_setbuf(iscan->dev, "iscan", iscan->iscan_ex_params_p, \
+               iscan->iscan_ex_param_size, iscan->ioctlbuf, sizeof(iscan->ioctlbuf)))) {
+                       WL_ERROR(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
+                       err = -1;
+       }
 
        return err;
 }
@@ -2355,7 +2885,7 @@ wl_iw_timerfunc(ulong data)
        if (iscan) {
                iscan->timer_on = 0;
                if (iscan->iscan_state != ISCAN_STATE_IDLE) {
-                       WL_TRACE(("timer trigger\n"));
+                       WL_SCAN(("timer trigger\n"));
                        up(&iscan->sysioc_sem);
                }
        }
@@ -2381,9 +2911,9 @@ wl_iw_iscan_get(iscan_info_t *iscan)
        wl_iscan_results_t list;
        wl_scan_results_t *results;
        uint32 status;
+       int res;
 
-       
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        if (iscan->list_cur) {
                buf = iscan->list_cur;
                iscan->list_cur = buf->next;
@@ -2393,7 +2923,7 @@ wl_iw_iscan_get(iscan_info_t *iscan)
                if (!buf) {
                        WL_ERROR(("%s can't alloc iscan_buf_t : going to abort currect iscan\n", \
                                                __FUNCTION__));
-                       MUTEX_UNLOCK_WL_SCAN_SET();
+                       mutex_unlock(&wl_cache_lock);
                        return WL_SCAN_RESULTS_NO_MEM;
                }
                buf->next = NULL;
@@ -2416,71 +2946,82 @@ wl_iw_iscan_get(iscan_info_t *iscan)
 
        memset(&list, 0, sizeof(list));
        list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN);
-       (void) dev_iw_iovar_getbuf(
+       res = dev_iw_iovar_getbuf(
                iscan->dev,
                "iscanresults",
                &list,
                WL_ISCAN_RESULTS_FIXED_SIZE,
                buf->iscan_buf,
                WLC_IW_ISCAN_MAXLEN);
-       results->buflen = dtoh32(results->buflen);
-       results->version = dtoh32(results->version);
-       results->count = dtoh32(results->count);
-       WL_TRACE(("%s: results->count = %d\n", __func__, results->count));
-
-       //WL_TRACE(("results->buflen = %d\n", results->buflen));
-       status = dtoh32(list_buf->status);
-       MUTEX_UNLOCK_WL_SCAN_SET();
+       if (res == 0) {
+               results->buflen = dtoh32(results->buflen);
+               results->version = dtoh32(results->version);
+               results->count = dtoh32(results->count);
+               WL_SCAN(("results->count = %d\n", results->count));
+
+               WL_SCAN(("results->buflen = %d\n", results->buflen));
+               status = dtoh32(list_buf->status);
+       } else {
+               WL_ERROR(("%s returns error %d\n", __FUNCTION__, res));
+               status = WL_SCAN_RESULTS_NO_MEM;
+       }
+       mutex_unlock(&wl_cache_lock);
        return status;
 }
 
 static void wl_iw_force_specific_scan(iscan_info_t *iscan)
 {
-       WL_TRACE(("%s force Specific SCAN for %s\n", __FUNCTION__, g_specific_ssid.SSID));
+       WL_SCAN(("%s force Specific SCAN for %s\n", __FUNCTION__, g_specific_ssid.SSID));
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        rtnl_lock();
 #endif
-
        (void) dev_wlc_ioctl(iscan->dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid));
-
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        rtnl_unlock();
 #endif
 }
+
 static void wl_iw_send_scan_complete(iscan_info_t *iscan)
 {
 #ifndef SANDGATE2G
        union iwreq_data wrqu;
 
-#if !defined(CSCAN)
-       if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
-               g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_READY;
-#endif 
        memset(&wrqu, 0, sizeof(wrqu));
+
        wireless_send_event(iscan->dev, SIOCGIWSCAN, &wrqu, NULL);
-       WL_TRACE(("Send Event ISCAN complete\n"));
+#if defined(CONFIG_FIRST_SCAN)
+       if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
+               g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_READY;
+#endif
+       WL_SCAN(("Send Event ISCAN complete\n"));
 #endif 
 }
+
 static int
 _iscan_sysioc_thread(void *data)
 {
        uint32 status;
        iscan_info_t *iscan = (iscan_info_t *)data;
        static bool iscan_pass_abort = FALSE;
+
        DAEMONIZE("iscan_sysioc");
 
        status = WL_SCAN_RESULTS_PARTIAL;
        while (down_interruptible(&iscan->sysioc_sem) == 0) {
 
+               net_os_wake_lock(iscan->dev);
+
 #if defined(SOFTAP)
                if (ap_cfg_running) {
-                WL_TRACE(("%s skipping SCAN ops in AP mode !!!\n", __FUNCTION__));
-                continue;
+                       WL_SCAN(("%s skipping SCAN ops in AP mode !!!\n", __FUNCTION__));
+                       net_os_wake_unlock(iscan->dev);
+                       continue;
                }
-#endif 
+#endif
+
                if (iscan->timer_on) {
-                       del_timer(&iscan->timer);
                        iscan->timer_on = 0;
+                       del_timer_sync(&iscan->timer);
                }
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
@@ -2490,8 +3031,9 @@ _iscan_sysioc_thread(void *data)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
                rtnl_unlock();
 #endif
-       if  (g_scan_specified_ssid && (iscan_pass_abort == TRUE)) {
-               WL_TRACE(("%s Get results from specific scan status=%d\n", __FUNCTION__, status));
+
+               if (g_scan_specified_ssid && (iscan_pass_abort == TRUE)) {
+                       WL_SCAN(("%s Get results from specific scan status=%d\n", __FUNCTION__, status));
                        wl_iw_send_scan_complete(iscan);
                        iscan_pass_abort = FALSE;
                        status  = -1;
@@ -2499,32 +3041,32 @@ _iscan_sysioc_thread(void *data)
 
                switch (status) {
                        case WL_SCAN_RESULTS_PARTIAL:
-                               WL_TRACE(("iscanresults incomplete\n"));
+                               WL_SCAN(("iscanresults incomplete\n"));
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
                                rtnl_lock();
 #endif
-                               
+
                                wl_iw_iscan(iscan, NULL, WL_SCAN_ACTION_CONTINUE);
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
                                rtnl_unlock();
 #endif
-                               
+
                                mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
                                iscan->timer_on = 1;
                                break;
                        case WL_SCAN_RESULTS_SUCCESS:
-                               WL_TRACE(("iscanresults complete\n"));
+                               WL_SCAN(("iscanresults complete\n"));
                                iscan->iscan_state = ISCAN_STATE_IDLE;
                                wl_iw_send_scan_complete(iscan);
                                break;
                        case WL_SCAN_RESULTS_PENDING:
-                               WL_TRACE(("iscanresults pending\n"));
-                               
+                               WL_SCAN(("iscanresults pending\n"));
+
                                mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
                                iscan->timer_on = 1;
                                break;
                        case WL_SCAN_RESULTS_ABORTED:
-                               WL_TRACE(("iscanresults aborted\n"));
+                               WL_SCAN(("iscanresults aborted\n"));
                                iscan->iscan_state = ISCAN_STATE_IDLE;
                                if (g_scan_specified_ssid == 0)
                                        wl_iw_send_scan_complete(iscan);
@@ -2534,19 +3076,22 @@ _iscan_sysioc_thread(void *data)
                                }
                                break;
                        case WL_SCAN_RESULTS_NO_MEM:
-                               WL_TRACE(("iscanresults can't alloc memory: skip\n"));
+                               WL_SCAN(("iscanresults can't alloc memory: skip\n"));
                                iscan->iscan_state = ISCAN_STATE_IDLE;
                                break;
                        default:
-                               WL_TRACE(("iscanresults returned unknown status %d\n", status));
+                               WL_SCAN(("iscanresults returned unknown status %d\n", status));
                                break;
-                }
+               }
+
+               net_os_wake_unlock(iscan->dev);
        }
 
        if (iscan->timer_on) {
-               del_timer(&iscan->timer);
                iscan->timer_on = 0;
+               del_timer_sync(&iscan->timer);
        }
+
        complete_and_exit(&iscan->sysioc_exited, 0);
 }
 #endif 
@@ -2557,7 +3102,7 @@ static void
 wl_iw_set_ss_cache_timer_flag(void)
 {
        g_ss_cache_ctrl.m_timer_expired = 1;
-       //WL_TRACE(("%s called\n", __FUNCTION__));
+       WL_TRACE(("%s called\n", __FUNCTION__));
 }
 
 static int
@@ -2591,7 +3136,7 @@ wl_iw_free_ss_cache(void)
 
        WL_TRACE(("%s called\n", __FUNCTION__));
 
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
        node = *spec_scan_head;
 
@@ -2602,7 +3147,7 @@ wl_iw_free_ss_cache(void)
                kfree(cur);
        }
        *spec_scan_head = NULL;
-       MUTEX_UNLOCK_WL_SCAN_SET();
+       mutex_unlock(&wl_cache_lock);
 }
 
 
@@ -2618,10 +3163,10 @@ wl_iw_run_ss_cache_timer(int kick_off)
                if (kick_off) {
                        (*timer)->expires = jiffies + 30000 * HZ / 1000;        
                        add_timer(*timer);
-                       //WL_TRACE(("%s : timer starts \n", __FUNCTION__));
+                       WL_TRACE(("%s : timer starts \n", __FUNCTION__));
                } else {
                        del_timer_sync(*timer);
-                       //WL_TRACE(("%s : timer stops \n", __FUNCTION__));
+                       WL_TRACE(("%s : timer stops \n", __FUNCTION__));
                }
        }
 
@@ -2648,7 +3193,7 @@ wl_iw_reset_ss_cache(void)
        wl_iw_ss_cache_t *node, *prev, *cur;
        wl_iw_ss_cache_t **spec_scan_head;
 
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
        node = *spec_scan_head;
        prev = node;
@@ -2675,7 +3220,7 @@ wl_iw_reset_ss_cache(void)
                prev = node;
                node = node->next;
        }
-       MUTEX_UNLOCK_WL_SCAN_SET();
+       mutex_unlock(&wl_cache_lock);
 }
 
 
@@ -2688,13 +3233,13 @@ wl_iw_add_bss_to_ss_cache(wl_scan_results_t *ss_list)
        wl_bss_info_t *bi = NULL;
        int i;
 
-       
        if (!ss_list->count) {
                return 0;
        }
 
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
+
        for (i = 0; i < ss_list->count; i++) {
 
                node = *spec_scan_head;
@@ -2719,7 +3264,9 @@ wl_iw_add_bss_to_ss_cache(wl_scan_results_t *ss_list)
                }
                leaf = kmalloc(bi->length + WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN, GFP_KERNEL);
                if (!leaf) {
-                       MUTEX_UNLOCK_WL_SCAN_SET();
+                       WL_ERROR(("Memory alloc failure %d\n", \
+                               bi->length + WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN));
+                       mutex_unlock(&wl_cache_lock);
                        return -ENOMEM;
                }
 
@@ -2736,9 +3283,8 @@ wl_iw_add_bss_to_ss_cache(wl_scan_results_t *ss_list)
                        prev->next = leaf;
                }
        }
-       MUTEX_UNLOCK_WL_SCAN_SET();
+       mutex_unlock(&wl_cache_lock);
        return 0;
-
 }
 
 
@@ -2749,10 +3295,10 @@ __u16 *merged_len)
        wl_iw_ss_cache_t *node;
        wl_scan_results_t *list_merge;
 
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        node = g_ss_cache_ctrl.m_cache_head;
        for (;node;) {
-               list_merge = (wl_scan_results_t *)node;
+               list_merge = (wl_scan_results_t *)&node->buflen;
                WL_TRACE(("%s: Cached Specific APs list=%d\n", __FUNCTION__, list_merge->count));
                if (buflen_from_user - *merged_len > 0) {
                        *merged_len += (__u16) wl_iw_get_scan_prep(list_merge, info,
@@ -2764,7 +3310,7 @@ __u16 *merged_len)
                }
                node = node->next;
        }
-       MUTEX_UNLOCK_WL_SCAN_SET();
+       mutex_unlock(&wl_cache_lock);
        return 0;
 }
 
@@ -2776,7 +3322,7 @@ wl_iw_delete_bss_from_ss_cache(void *addr)
        wl_iw_ss_cache_t *node, *prev;
        wl_iw_ss_cache_t **spec_scan_head;
 
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
        node = *spec_scan_head;
        prev = node;
@@ -2799,12 +3345,11 @@ wl_iw_delete_bss_from_ss_cache(void *addr)
        }
 
        memset(addr, 0, ETHER_ADDR_LEN);
-       MUTEX_UNLOCK_WL_SCAN_SET();
+       mutex_unlock(&wl_cache_lock);
        return 0;
-
 }
 
-#endif 
+#endif
 
 
 static int
@@ -2816,30 +3361,25 @@ wl_iw_set_scan(
 )
 {
        int error;
-       WL_TRACE(("\n:%s dev:%s: SIOCSIWSCAN : SCAN\n", __FUNCTION__, dev->name));
-
+       WL_TRACE(("%s dev:%s: SIOCSIWSCAN : SCAN\n", __FUNCTION__, dev->name));
 
 #if defined(CSCAN)
-               WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
-               return -EINVAL;
+       WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
+       return -EINVAL;
 #endif 
 
 #if defined(SOFTAP)
-       
        if (ap_cfg_running) {
                WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
                return 0;
        }
-#endif 
+#endif
 
-       
        if (g_onoff == G_WLAN_SET_OFF)
                return 0;
 
-       
        memset(&g_specific_ssid, 0, sizeof(g_specific_ssid));
 #ifndef WL_IW_USE_ISCAN
-       
        g_scan_specified_ssid = 0;
 #endif 
 
@@ -2848,17 +3388,17 @@ wl_iw_set_scan(
        if (wrqu->data.length == sizeof(struct iw_scan_req)) {
                if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                        struct iw_scan_req *req = (struct iw_scan_req *)extra;
+#if defined(CONFIG_FIRST_SCAN)
                        if (g_first_broadcast_scan != BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-                               
-                               WL_TRACE(("%s Ignoring SC %s first BC is not done = %d\n", \
+                               WL_ERROR(("%s Ignoring SC %s first BC is not done = %d\n", \
                                                __FUNCTION__, req->essid, \
                                                g_first_broadcast_scan));
                                return -EBUSY;
                        }
+#endif
                        if (g_scan_specified_ssid) {
-                               WL_TRACE(("%s Specific SCAN is not done ignore scan for = %s \n", \
+                               WL_SCAN(("%s Specific SCAN is not done ignore scan for = %s \n", \
                                        __FUNCTION__, req->essid));
-                               
                                return -EBUSY;
                        }
                        else {
@@ -2875,8 +3415,7 @@ wl_iw_set_scan(
 #endif 
        
        if ((error = dev_wlc_ioctl(dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid)))) {
-               WL_TRACE(("#### Set SCAN for %s failed with %d\n", g_specific_ssid.SSID, error));
-               
+               WL_SCAN(("Set SCAN for %s failed with %d\n", g_specific_ssid.SSID, error));
                g_scan_specified_ssid = 0;
                return -EBUSY;
        }
@@ -2891,17 +3430,16 @@ wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag)
        wlc_ssid_t ssid;
        iscan_info_t *iscan = g_iscan;
 
-#if !defined(CSCAN)
-       
+#if defined(CONFIG_FIRST_SCAN)
        if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_IDLE) {
                g_first_broadcast_scan = BROADCAST_SCAN_FIRST_STARTED;
-               WL_TRACE(("%s: First Brodcast scan was forced\n", __FUNCTION__));
+               WL_SCAN(("%s: First Brodcast scan was forced\n", __FUNCTION__));
        }
        else if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED) {
-               WL_TRACE(("%s: ignore ISCAN request first BS is not done yet\n", __FUNCTION__));
+               WL_SCAN(("%s: ignore ISCAN request first BS is not done yet\n", __FUNCTION__));
                return 0;
        }
-#endif 
+#endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        if (flag)
@@ -2911,7 +3449,7 @@ wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag)
        dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &iscan->scan_flag, sizeof(iscan->scan_flag));
        wl_iw_set_event_mask(dev);
 
-       WL_TRACE(("+++: Set Broadcast ISCAN\n"));
+       WL_SCAN(("+++: Set Broadcast ISCAN\n"));
        
        memset(&ssid, 0, sizeof(ssid));
 
@@ -2933,6 +3471,7 @@ wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag)
 
        return 0;
 }
+
 static int
 wl_iw_iscan_set_scan(
        struct net_device *dev,
@@ -2943,41 +3482,47 @@ wl_iw_iscan_set_scan(
 {
        wlc_ssid_t ssid;
        iscan_info_t *iscan = g_iscan;
+       int ret = 0;
 
-       WL_TRACE(("%s: SIOCSIWSCAN : ISCAN\n", dev->name));
+       WL_SCAN(("%s: SIOCSIWSCAN : ISCAN\n", dev->name));
 
 #if defined(CSCAN)
-               WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
-               return -EINVAL;
-#endif 
+       WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
+       return -EINVAL;
+#endif
+
+       net_os_wake_lock(dev);
 
-       
 #if defined(SOFTAP)
        if (ap_cfg_running) {
-               WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
-               return 0;
+               WL_SCAN(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
+               goto set_scan_end;
        }
 #endif
-       
+
        if (g_onoff == G_WLAN_SET_OFF) {
-               WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
-               return 0;
+               WL_SCAN(("%s: driver is not up yet after START\n", __FUNCTION__));
+               goto set_scan_end;
        }
 
-       
+#ifdef PNO_SUPPORT
+       if  (dhd_dev_get_pno_status(dev)) {
+               WL_SCAN(("%s: Scan called when PNO is active\n", __FUNCTION__));
+       }
+#endif
+
        if ((!iscan) || (iscan->sysioc_pid < 0)) {
-               WL_TRACE(("%s use backup if iscan thread is not successful\n", \
-                        __FUNCTION__));
-               return wl_iw_set_scan(dev, info, wrqu, extra);
+               WL_ERROR(("%s error\n", __FUNCTION__));
+               goto set_scan_end;
        }
 
        if (g_scan_specified_ssid) {
-               WL_TRACE(("%s Specific SCAN already running ignoring BC scan\n", \
+               WL_SCAN(("%s Specific SCAN already running ignoring BC scan\n", \
                                __FUNCTION__));
-               return EBUSY;
+               ret = EBUSY;
+               goto set_scan_end;
        }
 
-       
        memset(&ssid, 0, sizeof(ssid));
 
 #if WIRELESS_EXT > 17
@@ -2986,35 +3531,47 @@ wl_iw_iscan_set_scan(
                if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
                        int as = 0;
                        struct iw_scan_req *req = (struct iw_scan_req *)extra;
-#if !defined(CSCAN)
-                       if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-                               
-                               WL_TRACE(("%s First ISCAN in progress : ignoring SC = %s\n", \
-                                        __FUNCTION__, req->essid));
-                               return -EBUSY;
-                       }
-#endif 
                        ssid.SSID_len = MIN(sizeof(ssid.SSID), req->essid_len);
                        memcpy(ssid.SSID, req->essid, ssid.SSID_len);
                        ssid.SSID_len = htod32(ssid.SSID_len);
                        dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &as, sizeof(as));
                        wl_iw_set_event_mask(dev);
-                       return wl_iw_set_scan(dev, info, wrqu, extra);
+                       ret = wl_iw_set_scan(dev, info, wrqu, extra);
+                       goto set_scan_end;
                }
                else {
                        g_scan_specified_ssid = 0;
 
                        if (iscan->iscan_state == ISCAN_STATE_SCANING) {
-                               WL_TRACE(("%s ISCAN already in progress \n", __FUNCTION__));
-                               return 0;
+                               WL_SCAN(("%s ISCAN already in progress \n", __FUNCTION__));
+                               goto set_scan_end;
                        }
                }
        }
 #endif 
 
+#if defined(CONFIG_FIRST_SCAN) && !defined(CSCAN)
+       if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
+               if (++g_first_counter_scans == MAX_ALLOWED_BLOCK_SCAN_FROM_FIRST_SCAN) {
+
+                       WL_ERROR(("%s Clean up First scan flag which is %d\n", \
+                                __FUNCTION__, g_first_broadcast_scan));
+                       g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
+               }
+               else {
+                       WL_ERROR(("%s Ignoring Broadcast Scan:First Scan is not done yet %d\n", \
+                                       __FUNCTION__, g_first_counter_scans));
+                       ret = -EBUSY;
+                       goto set_scan_end;
+               }
+       }
+#endif
+
        wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
 
-       return 0;
+set_scan_end:
+       net_os_wake_unlock(dev);
+       return ret;
 }
 #endif 
 
@@ -3022,17 +3579,13 @@ wl_iw_iscan_set_scan(
 static bool
 ie_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, int *tlvs_len)
 {
-
-
        uint8 *ie = *wpaie;
 
-       
        if ((ie[1] >= 6) &&
                !bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x01"), 4)) {
                return TRUE;
        }
 
-       
        ie += ie[1] + 2;
        
        *tlvs_len -= (int)(ie - *tlvs);
@@ -3044,17 +3597,13 @@ ie_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, int *tlvs_len)
 static bool
 ie_is_wps_ie(uint8 **wpsie, uint8 **tlvs, int *tlvs_len)
 {
-
-
        uint8 *ie = *wpsie;
 
-       
        if ((ie[1] >= 4) &&
                !bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x04"), 4)) {
                return TRUE;
        }
 
-       
        ie += ie[1] + 2;
        
        *tlvs_len -= (int)(ie - *tlvs);
@@ -3174,6 +3723,7 @@ wl_iw_handle_scanresults_ies(char **event_p, char *end,
        return 0;
 }
 
+#ifndef CSCAN
 static uint
 wl_iw_get_scan_prep(
        wl_scan_results_t *list,
@@ -3186,10 +3736,12 @@ wl_iw_get_scan_prep(
        wl_bss_info_t *bi = NULL;
        char *event = extra, *end = extra + max_size - WE_ADD_EVENT_FIX, *value;
        int     ret = 0;
+       int channel;
 
-       ASSERT(list);
-
-       
+       if (!list) {
+               WL_ERROR(("%s: Null list pointer",__FUNCTION__));
+               return ret;
+       }
 
        for (i = 0; i < list->count && i < IW_MAX_AP; i++)
        {
@@ -3197,13 +3749,12 @@ wl_iw_get_scan_prep(
                        WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
                                __FUNCTION__, list->version));
                        return ret;
-                }
+               }
 
                bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
 
                WL_TRACE(("%s : %s\n", __FUNCTION__, bi->SSID));
 
-               
                iwe.cmd = SIOCGIWAP;
                iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
                memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
@@ -3214,7 +3765,6 @@ wl_iw_get_scan_prep(
                iwe.u.data.flags = 1;
                event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
 
-               
                if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
                        iwe.cmd = SIOCGIWMODE;
                        if (dtoh16(bi->capability) & DOT11_CAP_ESS)
@@ -3224,25 +3774,22 @@ wl_iw_get_scan_prep(
                        event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
                }
 
-               
                iwe.cmd = SIOCGIWFREQ;
-               iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
-                       CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
+               channel = (bi->ctl_ch == 0) ? CHSPEC_CHANNEL(bi->chanspec) : bi->ctl_ch;
+               iwe.u.freq.m = wf_channel2mhz(channel,
+                       channel <= CH_MAX_2G_CHANNEL ?
                        WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
                iwe.u.freq.e = 6;
                event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
 
-               
                iwe.cmd = IWEVQUAL;
                iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
                iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
                iwe.u.qual.noise = 0x100 + bi->phy_noise;
                event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
 
-               
-                wl_iw_handle_scanresults_ies(&event, end, info, bi);
+               wl_iw_handle_scanresults_ies(&event, end, info, bi);
 
-               
                iwe.cmd = SIOCGIWENCODE;
                if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
                        iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
@@ -3251,16 +3798,14 @@ wl_iw_get_scan_prep(
                iwe.u.data.length = 0;
                event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
 
-               
                if (bi->rateset.count) {
                        if (((event -extra) + IW_EV_LCP_LEN) <= (uintptr)end) {
                                value = event + IW_EV_LCP_LEN;
                                iwe.cmd = SIOCGIWRATE;
-                               
+
                                iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
                                for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
-                                       iwe.u.bitrate.value =
-                                               (bi->rateset.rates[j] & 0x7f) * 500000;
+                                       iwe.u.bitrate.value = (bi->rateset.rates[j] & 0x7f) * 500000;
                                        value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
                                                IW_EV_PARAM_LEN);
                                }
@@ -3292,7 +3837,7 @@ wl_iw_get_scan(
        uint buflen_from_user = dwrq->length;
        uint len =  G_SCAN_RESULTS;
        __u16 len_ret = 0;
-#if  !defined(CSCAN)
+#if !defined(CSCAN)
        __u16 merged_len = 0;
 #endif
 #if defined(WL_IW_USE_ISCAN)
@@ -3300,9 +3845,8 @@ wl_iw_get_scan(
        iscan_buf_t * p_buf;
 #if  !defined(CSCAN)
        uint32 counter = 0;
-#endif 
-#endif 
-
+#endif
+#endif
        WL_TRACE(("%s: buflen_from_user %d: \n", dev->name, buflen_from_user));
 
        if (!extra) {
@@ -3310,14 +3854,13 @@ wl_iw_get_scan(
                return -EINVAL;
        }
 
-       
        if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
                return error;
        ci.scan_channel = dtoh32(ci.scan_channel);
        if (ci.scan_channel)
                return -EAGAIN;
 
-#if  !defined(CSCAN)
+#if !defined(CSCAN)
        if (g_ss_cache_ctrl.m_timer_expired) {
                wl_iw_free_ss_cache();
                g_ss_cache_ctrl.m_timer_expired ^= 1;
@@ -3335,10 +3878,8 @@ wl_iw_get_scan(
        else {
                g_ss_cache_ctrl.m_cons_br_scan_cnt++;
        }
-#endif 
-
+#endif
 
-       
        if (g_scan_specified_ssid) {
                
                list = kmalloc(len, GFP_KERNEL);
@@ -3352,20 +3893,21 @@ wl_iw_get_scan(
        memset(list, 0, len);
        list->buflen = htod32(len);
        if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, len))) {
-               WL_TRACE(("%s: %s : Scan_results ERROR %d\n", dev->name, __FUNCTION__, len));
+               WL_ERROR(("%s: %s : Scan_results ERROR %d\n", dev->name, __FUNCTION__, error));
                dwrq->length = len;
-               if (g_scan_specified_ssid)
+               if (g_scan_specified_ssid) {
+                       g_scan_specified_ssid = 0;
                        kfree(list);
+               }
                return 0;
        }
        list->buflen = dtoh32(list->buflen);
        list->version = dtoh32(list->version);
        list->count = dtoh32(list->count);
 
-       
        if (list->version != WL_BSS_INFO_VERSION) {
-               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
-                        __FUNCTION__, list->version));
+               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n",
+                               __FUNCTION__, list->version));
                if (g_scan_specified_ssid) {
                        g_scan_specified_ssid = 0;
                        kfree(list);
@@ -3373,16 +3915,14 @@ wl_iw_get_scan(
                return -EINVAL;
        }
 
-#if  !defined(CSCAN)
+#if !defined(CSCAN)
        if (g_scan_specified_ssid) {
                
                wl_iw_add_bss_to_ss_cache(list);
                kfree(list);
        }
-#endif
 
-#if  !defined(CSCAN)
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
 #if defined(WL_IW_USE_ISCAN)
        if (g_scan_specified_ssid)
                WL_TRACE(("%s: Specified scan APs from scan=%d\n", __FUNCTION__, list->count));
@@ -3394,27 +3934,25 @@ wl_iw_get_scan(
                counter += list_merge->count;
                if (list_merge->count > 0)
                        len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info,
-                           extra+len_ret, buflen_from_user -len_ret);
+                               extra+len_ret, buflen_from_user -len_ret);
                p_buf = p_buf->next;
        }
        WL_TRACE(("%s merged with total Bcast APs=%d\n", __FUNCTION__, counter));
 #else
        list_merge = (wl_scan_results_t *) g_scan;
        len_ret = (__u16) wl_iw_get_scan_prep(list_merge, info, extra, buflen_from_user);
-#endif 
-       MUTEX_UNLOCK_WL_SCAN_SET();
+#endif
+       mutex_unlock(&wl_cache_lock);
        if (g_ss_cache_ctrl.m_link_down) {
-               
                wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
        }
-       
+
        wl_iw_merge_scan_cache(info, extra+len_ret, buflen_from_user-len_ret, &merged_len);
        len_ret += merged_len;
        wl_iw_run_ss_cache_timer(0);
        wl_iw_run_ss_cache_timer(1);
-#else  
+#else
 
-       
        if (g_scan_specified_ssid) {
                WL_TRACE(("%s: Specified scan APs in the list =%d\n", __FUNCTION__, list->count));
                len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
@@ -3437,13 +3975,13 @@ wl_iw_get_scan(
                if (list_merge->count > 0)
                        len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info, extra+len_ret,
                                buflen_from_user -len_ret);
-#endif 
+#endif
        }
        else {
                list = (wl_scan_results_t *) g_scan;
                len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
        }
-#endif 
+#endif
 
 #if defined(WL_IW_USE_ISCAN)
        
@@ -3459,6 +3997,7 @@ wl_iw_get_scan(
        WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, list->count));
        return 0;
 }
+#endif
 
 #if defined(WL_IW_USE_ISCAN)
 static int
@@ -3478,12 +4017,13 @@ wl_iw_iscan_get_scan(
        iscan_info_t *iscan = g_iscan;
        iscan_buf_t * p_buf;
        uint32  counter = 0;
+       uint8   channel;
 #if !defined(CSCAN)
        __u16 merged_len = 0;
        uint buflen_from_user = dwrq->length;
 #endif
 
-       WL_TRACE(("%s %s buflen_from_user %d:\n", dev->name, __FUNCTION__, dwrq->length));
+       WL_SCAN(("%s %s buflen_from_user %d:\n", dev->name, __FUNCTION__, dwrq->length));
 
 #if defined(SOFTAP)
        if (ap_cfg_running) {
@@ -3497,17 +4037,17 @@ wl_iw_iscan_get_scan(
                return -EINVAL;
        }
 
-#if !defined(CSCAN)
+#if defined(CONFIG_FIRST_SCAN)
        if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_READY) {
                WL_TRACE(("%s %s: first ISCAN results are NOT ready yet \n", \
                         dev->name, __FUNCTION__));
                return -EAGAIN;
        }
-#endif 
-       
+#endif
+
        if ((!iscan) || (iscan->sysioc_pid < 0)) {
-               WL_TRACE(("%ssysioc_pid\n", __FUNCTION__));
-               return wl_iw_get_scan(dev, info, dwrq, extra);
+               WL_ERROR(("%ssysioc_pid\n", __FUNCTION__));
+               return -EAGAIN;
        }
 
 #if !defined(CSCAN)
@@ -3520,18 +4060,17 @@ wl_iw_iscan_get_scan(
        }
        else {
                if (g_ss_cache_ctrl.m_link_down) {
-                       
                        wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
                }
                if (g_ss_cache_ctrl.m_prev_scan_mode || g_ss_cache_ctrl.m_cons_br_scan_cnt > 4) {
                        g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-                       
+
                        wl_iw_reset_ss_cache();
                }
                g_ss_cache_ctrl.m_prev_scan_mode = g_scan_specified_ssid;
                g_ss_cache_ctrl.m_cons_br_scan_cnt++;
        }
-#endif 
+#endif
 
        WL_TRACE(("%s: SIOCGIWSCAN GET broadcast results\n", dev->name));
        apcnt = 0;
@@ -3540,10 +4079,10 @@ wl_iw_iscan_get_scan(
        while (p_buf != iscan->list_cur) {
            list = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
 
-       counter += list->count;
+           counter += list->count;
 
            if (list->version != WL_BSS_INFO_VERSION) {
-               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
+               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n",
                         __FUNCTION__, list->version));
                return -EINVAL;
            }
@@ -3551,26 +4090,27 @@ wl_iw_iscan_get_scan(
            bi = NULL;
            for (ii = 0; ii < list->count && apcnt < IW_MAX_AP; apcnt++, ii++) {
                bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
-               ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
-                       WLC_IW_ISCAN_MAXLEN));
 
-               
+               if ((dtoh32(bi->length) > WLC_IW_ISCAN_MAXLEN) ||
+                   (((uintptr)bi + dtoh32(bi->length)) > ((uintptr)list + WLC_IW_ISCAN_MAXLEN))) {
+                       WL_ERROR(("%s: Scan results out of bounds: %u\n",__FUNCTION__,dtoh32(bi->length)));
+                       return -E2BIG;
+               }
+
                if (event + ETHER_ADDR_LEN + bi->SSID_len + IW_EV_UINT_LEN + IW_EV_FREQ_LEN +
                        IW_EV_QUAL_LEN >= end)
                        return -E2BIG;
-               
+
                iwe.cmd = SIOCGIWAP;
                iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
                memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
                event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
 
-               
                iwe.u.data.length = dtoh32(bi->SSID_len);
                iwe.cmd = SIOCGIWESSID;
                iwe.u.data.flags = 1;
                event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
 
-               
                if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
                        iwe.cmd = SIOCGIWMODE;
                        if (dtoh16(bi->capability) & DOT11_CAP_ESS)
@@ -3580,25 +4120,22 @@ wl_iw_iscan_get_scan(
                        event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
                }
 
-               
                iwe.cmd = SIOCGIWFREQ;
-               iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
-                       CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
+               channel = (bi->ctl_ch == 0) ? CHSPEC_CHANNEL(bi->chanspec) : bi->ctl_ch;
+               iwe.u.freq.m = wf_channel2mhz(channel,
+                       channel <= CH_MAX_2G_CHANNEL ?
                        WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
                iwe.u.freq.e = 6;
                event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
 
-               
                iwe.cmd = IWEVQUAL;
                iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
                iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
                iwe.u.qual.noise = 0x100 + bi->phy_noise;
                event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
 
-               
                wl_iw_handle_scanresults_ies(&event, end, info, bi);
 
-               
                iwe.cmd = SIOCGIWENCODE;
                if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
                        iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
@@ -3607,7 +4144,6 @@ wl_iw_iscan_get_scan(
                iwe.u.data.length = 0;
                event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
 
-               
                if (bi->rateset.count) {
                        if (event + IW_MAX_BITRATES*IW_EV_PARAM_LEN >= end)
                                return -E2BIG;
@@ -3631,21 +4167,17 @@ wl_iw_iscan_get_scan(
        dwrq->flags = 0;        
 
 #if !defined(CSCAN)
-       
        wl_iw_merge_scan_cache(info, event, buflen_from_user - dwrq->length, &merged_len);
        dwrq->length += merged_len;
        wl_iw_run_ss_cache_timer(0);
        wl_iw_run_ss_cache_timer(1);
-       
+#endif /* CSCAN */
+#if defined(CONFIG_FIRST_SCAN)
        g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
 #endif
 
        WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, counter));
 
-       
-       if (!dwrq->length)
-               return -EAGAIN;
-
        return 0;
 }
 #endif 
@@ -3659,10 +4191,11 @@ wl_iw_set_essid(
 )
 {
        int error;
+       wl_join_params_t join_params;
+       int join_params_size;
 
        WL_TRACE(("%s: SIOCSIWESSID\n", dev->name));
 
-
        
        memset(&g_ssid, 0, sizeof(g_ssid));
 
@@ -3680,11 +4213,24 @@ wl_iw_set_essid(
                g_ssid.SSID_len = 0;
        }
        g_ssid.SSID_len = htod32(g_ssid.SSID_len);
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &g_ssid, sizeof(g_ssid))))
+
+       memset(&join_params, 0, sizeof(join_params));
+       join_params_size = sizeof(join_params.ssid);
+
+       memcpy(&join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
+       join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
+       memcpy(&join_params.params.bssid, &ether_bcast, ETHER_ADDR_LEN);
+
+       wl_iw_ch_to_chanspec(g_wl_iw_params.target_channel, &join_params, &join_params_size);
+
+       if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, join_params_size))) {
+               WL_ERROR(("Invalid ioctl data=%d\n", error));
                return error;
+       }
 
        if (g_ssid.SSID_len) {
-               WL_TRACE(("%s: join SSID=%s\n", __FUNCTION__,  g_ssid.SSID));
+               WL_TRACE(("%s: join SSID=%s ch=%d\n", __FUNCTION__, \
+                       g_ssid.SSID,  g_wl_iw_params.target_channel));
        }
        return 0;
 }
@@ -3712,7 +4258,6 @@ wl_iw_get_essid(
 
        ssid.SSID_len = dtoh32(ssid.SSID_len);
 
-       
        memcpy(extra, ssid.SSID, ssid.SSID_len);
 
        dwrq->length = ssid.SSID_len;
@@ -3737,7 +4282,6 @@ wl_iw_set_nick(
        if (!extra)
                return -EINVAL;
 
-       
        if (dwrq->length > sizeof(iw->nickname))
                return -E2BIG;
 
@@ -4353,7 +4897,7 @@ wl_iw_set_encodeext(
        int error;
        struct iw_encode_ext *iwe;
 
-       WL_TRACE(("%s: SIOCSIWENCODEEXT\n", dev->name));
+       WL_WSEC(("%s: SIOCSIWENCODEEXT\n", dev->name));
 
        CHECK_EXTRA_FOR_NULL(extra);
 
@@ -4479,7 +5023,6 @@ wl_iw_set_pmksa(
        char eabuf[ETHER_ADDR_STR_LEN];
 
        WL_WSEC(("%s: SIOCSIWPMKSA\n", dev->name));
-
        CHECK_EXTRA_FOR_NULL(extra);
 
        iwpmksa = (struct iw_pmksa *)extra;
@@ -4496,8 +5039,7 @@ wl_iw_set_pmksa(
                        uint j;
                        pmkidptr = &pmkid;
 
-                       bcopy(&iwpmksa->bssid.sa_data[0], &pmkidptr->pmkid[0].BSSID, \
-                               ETHER_ADDR_LEN);
+                       bcopy(&iwpmksa->bssid.sa_data[0], &pmkidptr->pmkid[0].BSSID, ETHER_ADDR_LEN);
                        bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID, WPA2_PMKID_LEN);
 
                        WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_REMOVE - PMKID: %s = ",
@@ -4545,6 +5087,7 @@ wl_iw_set_pmksa(
                }
                else
                        ret = -EINVAL;
+
                {
                        uint j;
                        uint k;
@@ -4557,7 +5100,7 @@ wl_iw_set_pmksa(
                        WL_WSEC(("\n"));
                }
        }
-       WL_WSEC(("PRINTING pmkid LIST - No of elements %d\n", pmkid_list.pmkids.npmkid));
+       WL_WSEC(("PRINTING pmkid LIST - No of elements %d, ret = %d\n", pmkid_list.pmkids.npmkid, ret));
        for (i = 0; i < pmkid_list.pmkids.npmkid; i++) {
                uint j;
                WL_WSEC(("PMKID[%d]: %s = ", i,
@@ -4570,8 +5113,7 @@ wl_iw_set_pmksa(
        WL_WSEC(("\n"));
 
        if (!ret)
-               ret = dev_wlc_bufvar_set(dev, "pmkid_info", (char *)&pmkid_list, \
-                       sizeof(pmkid_list));
+               ret = dev_wlc_bufvar_set(dev, "pmkid_info", (char *)&pmkid_list, sizeof(pmkid_list));
        return ret;
 }
 #endif 
@@ -4585,7 +5127,7 @@ wl_iw_get_encodeext(
        char *extra
 )
 {
-       WL_TRACE(("%s: SIOCGIWENCODEEXT\n", dev->name));
+       WL_WSEC(("%s: SIOCGIWENCODEEXT\n", dev->name));
        return 0;
 }
 
@@ -4603,7 +5145,7 @@ wl_iw_set_wpaauth(
        int val = 0;
        wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
 
-       WL_TRACE(("%s: SIOCSIWAUTH\n", dev->name));
+       WL_WSEC(("%s: SIOCSIWAUTH\n", dev->name));
 
 #if defined(SOFTAP)
        if (ap_cfg_running) {
@@ -4615,7 +5157,7 @@ wl_iw_set_wpaauth(
        paramid = vwrq->flags & IW_AUTH_INDEX;
        paramval = vwrq->value;
 
-       WL_TRACE(("%s: SIOCSIWAUTH, paramid = 0x%0x, paramval = 0x%0x\n",
+       WL_WSEC(("%s: SIOCSIWAUTH, paramid = 0x%0x, paramval = 0x%0x\n",
                dev->name, paramid, paramval));
 
        switch (paramid) {
@@ -4631,7 +5173,7 @@ wl_iw_set_wpaauth(
 #endif 
                else if (paramval & IW_AUTH_WAPI_VERSION_1)
                        val = WPA_AUTH_WAPI;
-               WL_INFORM(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
+               WL_WSEC(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
                if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
                        return error;
                break;
@@ -4659,26 +5201,30 @@ wl_iw_set_wpaauth(
 
                if (iw->privacy_invoked && !val) {
                        WL_WSEC(("%s: %s: 'Privacy invoked' TRUE but clearing wsec, assuming "
-                                "we're a WPS enrollee\n", dev->name, __FUNCTION__));
+                               "we're a WPS enrollee\n", dev->name, __FUNCTION__));
                        if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
-                               WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
+                               WL_ERROR(("Failed to set iovar is_WPS_enrollee\n"));
                                return error;
                        }
                } else if (val) {
                        if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
-                               WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
+                               WL_ERROR(("Failed to clear iovar is_WPS_enrollee\n"));
                                return error;
                        }
                }
 
-               if ((error = dev_wlc_intvar_set(dev, "wsec", val)))
+               if ((error = dev_wlc_intvar_set(dev, "wsec", val))) {
+                       WL_ERROR(("Failed to set 'wsec'iovar\n"));
                        return error;
+               }
 
                break;
 
        case IW_AUTH_KEY_MGMT:
-               if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
+               if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val))) {
+                       WL_ERROR(("Failed to get 'wpa_auth'iovar\n"));
                        return error;
+               }
 
                if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
                        if (paramval & IW_AUTH_KEY_MGMT_PSK)
@@ -4696,18 +5242,22 @@ wl_iw_set_wpaauth(
 #endif 
                if (paramval & (IW_AUTH_KEY_MGMT_WAPI_PSK | IW_AUTH_KEY_MGMT_WAPI_CERT))
                        val = WPA_AUTH_WAPI;
-               WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
-               if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
+               WL_WSEC(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
+               if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val))) {
+                       WL_ERROR(("Failed to set 'wpa_auth'iovar\n"));
                        return error;
+               }
 
                break;
        case IW_AUTH_TKIP_COUNTERMEASURES:
-               dev_wlc_bufvar_set(dev, "tkip_countermeasures", (char *)&paramval, 1);
+               if ((error = dev_wlc_bufvar_set(dev, "tkip_countermeasures", \
+                                               (char *)&paramval, sizeof(paramval))))
+                       WL_WSEC(("%s: tkip_countermeasures failed %d\n", __FUNCTION__, error));
                break;
 
        case IW_AUTH_80211_AUTH_ALG:
                
-               WL_INFORM(("Setting the D11auth %d\n", paramval));
+               WL_WSEC(("Setting the D11auth %d\n", paramval));
                if (paramval == IW_AUTH_ALG_OPEN_SYSTEM)
                        val = 0;
                else if (paramval == IW_AUTH_ALG_SHARED_KEY)
@@ -4724,15 +5274,21 @@ wl_iw_set_wpaauth(
                if (paramval == 0) {
                        iw->pwsec = 0;
                        iw->gwsec = 0;
-                       if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
+                       if ((error = dev_wlc_intvar_get(dev, "wsec", &val))) {
+                               WL_ERROR(("Failed to get 'wsec'iovar\n"));
                                return error;
+                       }
                        if (val & (TKIP_ENABLED | AES_ENABLED)) {
                                val &= ~(TKIP_ENABLED | AES_ENABLED);
                                dev_wlc_intvar_set(dev, "wsec", val);
                        }
                        val = 0;
-               WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
-                       dev_wlc_intvar_set(dev, "wpa_auth", 0);
+
+                       WL_INFORM(("%s: %d: setting wpa_auth to %d\n",
+                               __FUNCTION__, __LINE__, val));
+                       error = dev_wlc_intvar_set(dev, "wpa_auth", 0);
+                       if (error)
+                               WL_ERROR(("Failed to set 'wpa_auth'iovar\n"));
                        return error;
                }
 
@@ -4740,11 +5296,17 @@ wl_iw_set_wpaauth(
                break;
 
        case IW_AUTH_DROP_UNENCRYPTED:
-               dev_wlc_bufvar_set(dev, "wsec_restrict", (char *)&paramval, 1);
+               error = dev_wlc_bufvar_set(dev, "wsec_restrict", \
+                                  (char *)&paramval, sizeof(paramval));
+               if (error)
+                       WL_ERROR(("%s: wsec_restrict %d\n", __FUNCTION__, error));
                break;
 
        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", (char *)&paramval, 1);
+               error = dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", \
+                                  (char *)&paramval, sizeof(paramval));
+               if (error)
+                       WL_WSEC(("%s: rx_unencrypted_eapol %d\n", __FUNCTION__, error));
                break;
 
 #if WIRELESS_EXT > 17
@@ -4767,7 +5329,6 @@ wl_iw_set_wpaauth(
                                return error;
 
                        if (!(IW_WSEC_ENABLED(wsec))) {
-                               
 
                                if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
                                        WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
@@ -4782,7 +5343,7 @@ wl_iw_set_wpaauth(
                }
                break;
        }
-#endif 
+#endif
        case IW_AUTH_WAPI_ENABLED:
                if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
                        return error;
@@ -4874,15 +5435,24 @@ wl_iw_get_wpaauth(
 
                break;
        case IW_AUTH_TKIP_COUNTERMEASURES:
-               dev_wlc_bufvar_get(dev, "tkip_countermeasures", (char *)&paramval, 1);
+               error = dev_wlc_bufvar_get(dev, "tkip_countermeasures", \
+                                                       (char *)&paramval, sizeof(paramval));
+               if (error)
+                       WL_ERROR(("%s get tkip_countermeasures %d\n", __FUNCTION__, error));
                break;
 
        case IW_AUTH_DROP_UNENCRYPTED:
-               dev_wlc_bufvar_get(dev, "wsec_restrict", (char *)&paramval, 1);
+               error = dev_wlc_bufvar_get(dev, "wsec_restrict", \
+                                          (char *)&paramval, sizeof(paramval));
+               if (error)
+                       WL_ERROR(("%s get wsec_restrict %d\n", __FUNCTION__, error));
                break;
 
        case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", (char *)&paramval, 1);
+               error = dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", \
+                                                  (char *)&paramval, sizeof(paramval));
+               if (error)
+                       WL_ERROR(("%s get rx_unencrypted_eapol %d\n", __FUNCTION__, error));
                break;
 
        case IW_AUTH_80211_AUTH_ALG:
@@ -4910,13 +5480,12 @@ wl_iw_get_wpaauth(
        case IW_AUTH_PRIVACY_INVOKED:
                paramval = iw->privacy_invoked;
                break;
-
 #endif 
        }
        vwrq->value = paramval;
        return 0;
 }
-#endif 
+#endif
 
 
 #ifdef SOFTAP
@@ -4940,12 +5509,10 @@ wl_iw_parse_wep(char *keystr, wl_wsec_key_t *key)
        case 28:
        case 34:
        case 66:
-               
                if (!strnicmp(keystr, "0x", 2))
                        keystr += 2;
                else
                        return -1;
-               
        case 10:
        case 26:
        case 32:
@@ -4969,7 +5536,6 @@ wl_iw_parse_wep(char *keystr, wl_wsec_key_t *key)
                key->algo = CRYPTO_ALGO_WEP128;
                break;
        case 16:
-               
                key->algo = CRYPTO_ALGO_AES_CCM;
                break;
        case 32:
@@ -4979,7 +5545,6 @@ wl_iw_parse_wep(char *keystr, wl_wsec_key_t *key)
                return -1;
        }
 
-       
        key->flags |= WL_PRIMARY_KEY;
 
        return 0;
@@ -4987,14 +5552,14 @@ wl_iw_parse_wep(char *keystr, wl_wsec_key_t *key)
 
 #ifdef EXT_WPA_CRYPTO
 #define SHA1HashSize 20
-extern void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
-                                               int iterations, u8 *buf, size_t buflen);
+extern void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len,
+                               int iterations, u8 *buf, size_t buflen);
 
 #else
 
 #define SHA1HashSize 20
-int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
-                                               int iterations, u8 *buf, size_t buflen)
+int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len,
+                               int iterations, u8 *buf, size_t buflen)
 {
        WL_ERROR(("WARNING: %s is not implemented !!!\n", __FUNCTION__));
        return -1;
@@ -5041,7 +5606,6 @@ int dev_iw_read_cfg1_bss_var(struct net_device *dev, int *val)
 }
 
 
-
 #ifndef AP_ONLY
 static int wl_bssiovar_mkbuf(
                        const char *iovar,
@@ -5053,37 +5617,32 @@ static int wl_bssiovar_mkbuf(
                        int *perr)
 {
        const char *prefix = "bsscfg:";
-       int8p;
+       int8 *p;
        uint prefixlen;
        uint namelen;
        uint iolen;
 
-       prefixlen = strlen(prefix);     
-       namelen = strlen(iovar) + 1;    
+       prefixlen = strlen(prefix);
+       namelen = strlen(iovar) + 1;
        iolen = prefixlen + namelen + sizeof(int) + paramlen;
 
-       
        if (buflen < 0 || iolen > (uint)buflen) {
                *perr = BCME_BUFTOOSHORT;
                return 0;
        }
 
-       p = (int8*)bufptr;
+       p = (int8 *)bufptr;
 
-       
        memcpy(p, prefix, prefixlen);
        p += prefixlen;
 
-       
        memcpy(p, iovar, namelen);
        p += namelen;
 
-       
        bssidx = htod32(bssidx);
        memcpy(p, &bssidx, sizeof(int32));
        p += sizeof(int32);
 
-       
        if (paramlen)
                memcpy(p, param, paramlen);
 
@@ -5093,8 +5652,6 @@ static int wl_bssiovar_mkbuf(
 #endif 
 
 
-
-
 int get_user_params(char *user_params, struct iw_point *dwrq)
 {
        int ret = 0;
@@ -5113,9 +5670,6 @@ int get_user_params(char *user_params, struct iw_point *dwrq)
 
 #define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
 
-#endif /* SOFTAP */
-
-
 #if defined(CSCAN)
 
 static int
@@ -5127,16 +5681,22 @@ wl_iw_combined_scan_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nss
        int i;
        iscan_info_t *iscan = g_iscan;
 
-       WL_TRACE(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, nchan));
+       WL_SCAN(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, nchan));
 
        if ((!dev) && (!g_iscan) && (!iscan->iscan_ex_params_p)) {
                WL_ERROR(("%s error exit\n", __FUNCTION__));
                err = -1;
+               goto exit;
        }
 
+#ifdef PNO_SUPPORT
+       if  (dhd_dev_get_pno_status(dev)) {
+               WL_ERROR(("%s: Scan called when PNO is active\n", __FUNCTION__));
+       }
+#endif
+
        params_size += WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
 
-       
        if (nssid > 0) {
                i = OFFSETOF(wl_scan_params_t, channel_list) + nchan * sizeof(uint16);
                i = ROUNDUP(i, sizeof(uint32));
@@ -5153,7 +5713,6 @@ wl_iw_combined_scan_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nss
                p = (char*)iscan->iscan_ex_params_p->params.channel_list + nchan * sizeof(uint16);
        }
 
-       
        iscan->iscan_ex_params_p->params.channel_num = \
                htod32((nssid << WL_SCAN_PARAMS_NSSID_SHIFT) | \
                                        (nchan & WL_SCAN_PARAMS_COUNT_MASK));
@@ -5162,7 +5721,6 @@ wl_iw_combined_scan_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nss
        (uint)((iscan->iscan_ex_params_p->params.channel_num >> WL_SCAN_PARAMS_NSSID_SHIFT) & \
                               WL_SCAN_PARAMS_COUNT_MASK);
 
-       
        params_size = (int) (p - (char*)iscan->iscan_ex_params_p + nssid * sizeof(wlc_ssid_t));
        iscan->iscan_ex_param_size = params_size;
 
@@ -5207,7 +5765,7 @@ wl_iw_combined_scan_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nss
        if ((err = dev_iw_iovar_setbuf(dev, "iscan", iscan->iscan_ex_params_p, \
                        iscan->iscan_ex_param_size, \
                        iscan->ioctlbuf, sizeof(iscan->ioctlbuf)))) {
-                       WL_TRACE(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
+                       WL_ERROR(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
                        err = -1;
        }
 
@@ -5257,7 +5815,6 @@ static int iwpriv_set_cscan(struct net_device *dev, struct iw_request_info *info
 
                str_ptr = extra;
 
-               
                if (strncmp(str_ptr, GET_SSID, strlen(GET_SSID))) {
                        WL_ERROR(("%s Error: extracting SSID='' string\n", __FUNCTION__));
                        goto exit_proc;
@@ -5270,8 +5827,12 @@ static int iwpriv_set_cscan(struct net_device *dev, struct iw_request_info *info
                        return -1;
                }
 
+               if (iscan->iscan_ex_param_size > WLC_IOCTL_MAXLEN) {
+                       WL_ERROR(("%s wrong ex_param_size %d", \
+                               __FUNCTION__, iscan->iscan_ex_param_size));
+                       return -1;
+               }
                memset(iscan->iscan_ex_params_p, 0, iscan->iscan_ex_param_size);
-               ASSERT(iscan->iscan_ex_param_size < WLC_IOCTL_MAXLEN);
 
                
                wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, NULL);
@@ -5304,11 +5865,9 @@ static int iwpriv_set_cscan(struct net_device *dev, struct iw_request_info *info
                get_parmeter_from_string(&str_ptr, GET_SCAN_TYPE, PTYPE_INTDEC, \
                                        &iscan->iscan_ex_params_p->params.scan_type, 1);
 
-               
                res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
 
        } else {
-                
                  WL_ERROR(("IWPRIV argument len = 0 \n"));
                  return -1;
        }
@@ -5361,15 +5920,18 @@ wl_iw_set_cscan(
                __FUNCTION__, info->cmd, info->flags,
                wrqu->data.pointer, wrqu->data.length));
 
+       net_os_wake_lock(dev);
+
        if (g_onoff == G_WLAN_SET_OFF) {
                WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
-               return -1;
+               goto exit_proc;
        }
 
+
        if (wrqu->data.length < (strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t))) {
                WL_ERROR(("%s aggument=%d  less %d\n", __FUNCTION__, \
                        wrqu->data.length, strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t)));
-               return -1;
+               goto exit_proc;
        }
 
 #ifdef TLV_DEBUG
@@ -5490,39 +6052,67 @@ wl_iw_set_cscan(
                        goto exit_proc;
                }
 
-               
+#if defined(CONFIG_FIRST_SCAN)
+               if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
+                       if (++g_first_counter_scans == MAX_ALLOWED_BLOCK_SCAN_FROM_FIRST_SCAN) {
+
+                               WL_ERROR(("%s Clean up First scan flag which is %d\n", \
+                                                __FUNCTION__, g_first_broadcast_scan));
+                               g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
+                       }
+                       else {
+                               WL_ERROR(("%s Ignoring CSCAN : First Scan is not done yet %d\n", \
+                                               __FUNCTION__, g_first_counter_scans));
+                               res = -EBUSY;
+                               goto exit_proc;
+                       }
+               }
+#endif
+
                res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
 
 exit_proc:
+       net_os_wake_unlock(dev);
        return res;
 }
 
 #endif 
 
-
-
 #ifdef SOFTAP
-
 #ifndef AP_ONLY
+
 static int thr_wait_for_2nd_eth_dev(void *data)
 {
+       struct net_device *dev = (struct net_device *)data;
+       wl_iw_t *iw;
        int ret = 0;
+       unsigned long flags;
 
-       printk("==========> WARNING!!! we are in thr_wait_for_2nd_eth_dev!!!\n");
+       net_os_wake_lock(dev);
 
        DAEMONIZE("wl0_eth_wthread");
 
-       WL_TRACE(("\n>%s threda started:, PID:%x\n", __FUNCTION__, current->pid));
+       WL_TRACE(("\n>%s thread started:, PID:%x\n", __FUNCTION__, current->pid));
+       iw = *(wl_iw_t **)netdev_priv(dev);
+       if (!iw) {
+               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
+               ret = -1;
+               goto fail;
+       }
 
-/*     if (down_timeout(&ap_eth_sema,  msecs_to_jiffies(5000)) != 0) {
+#ifndef BCMSDIOH_STD
+       if (down_timeout(&ap_eth_sema,  msecs_to_jiffies(5000)) != 0) {
                WL_ERROR(("\n%s: sap_eth_sema timeout \n", __FUNCTION__));
                ret = -1;
                goto fail;
        }
-*/
+#endif
+
+       flags = dhd_os_spin_lock(iw->pub);
        if (!ap_net_dev) {
                WL_ERROR((" ap_net_dev is null !!!"));
                ret = -1;
+               dhd_os_spin_unlock(iw->pub, flags);
                goto fail;
        }
 
@@ -5531,19 +6121,21 @@ static int thr_wait_for_2nd_eth_dev(void *data)
 
        ap_cfg_running = TRUE;
 
-       bcm_mdelay(500); 
+       dhd_os_spin_unlock(iw->pub, flags);
+
+       bcm_mdelay(500);
 
-       
        wl_iw_send_priv_event(priv_dev, "AP_SET_CFG_OK");
 
 fail:
-
        WL_TRACE(("\n>%s, thread completed\n", __FUNCTION__));
 
+       net_os_wake_unlock(dev);
+
+       complete_and_exit(&ap_cfg_exited, 0);
        return ret;
 }
-#endif
-
+#endif 
 #ifndef AP_ONLY
 static int last_auto_channel = 6;
 #endif
@@ -5617,7 +6209,7 @@ static int get_softap_auto_channel(struct net_device *dev, struct ap_profile *ap
 
 fail :
        return res;
-} 
+}
 
 
 static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
@@ -5637,13 +6229,14 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
        int bsscfg_index = 1;
        char buf[WLC_IOCTL_SMLEN];
 #endif
-       wl_iw_t *iw;
 
        if (!dev) {
                WL_ERROR(("%s: dev is null\n", __FUNCTION__));
                return -1;
        }
 
+       net_os_wake_lock(dev);
+
        WL_SOFTAP(("wl_iw: set ap profile:\n"));
        WL_SOFTAP(("    ssid = '%s'\n", ap->ssid));
        WL_SOFTAP(("    security = '%s'\n", ap->sec));
@@ -5652,24 +6245,16 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
        WL_SOFTAP(("    channel = %d\n", ap->channel));
        WL_SOFTAP(("    max scb = %d\n", ap->max_scb));
 
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK_SOFTAP_SET(iw->pub);
-       WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_SET, "SoftAP_SET");
-       WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
-
 #ifdef AP_ONLY
        if (ap_cfg_running) {
-               wl_iw_softap_deassoc_stations(dev);
+               wl_iw_softap_deassoc_stations(dev, NULL);
                ap_cfg_running = FALSE;
        }
-#endif 
+#endif
 
-       
        if (ap_cfg_running == FALSE) {
 
 #ifndef AP_ONLY
-
-               
                sema_init(&ap_eth_sema, 0);
 
                mpc = 0;
@@ -5686,7 +6271,6 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
                }
 
 #ifdef AP_ONLY
-               
                apsta_var = 0;
                if ((res = dev_wlc_ioctl(dev, WLC_SET_AP, &apsta_var, sizeof(apsta_var)))) {
                        WL_ERROR(("%s fail to set apsta_var 0\n", __FUNCTION__));
@@ -5699,18 +6283,20 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
                }
                res = dev_wlc_ioctl(dev, WLC_GET_AP, &apsta_var, sizeof(apsta_var));
 #else
-               
                apsta_var = 1;
                iolen = wl_bssiovar_mkbuf("apsta",
                        bsscfg_index,  &apsta_var, sizeof(apsta_var)+4,
                        buf, sizeof(buf), &mkvar_err);
-               ASSERT(iolen);
+
+               if (iolen <= 0)
+                       goto fail;
+
                if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) < 0) {
                        WL_ERROR(("%s fail to set apsta \n", __FUNCTION__));
                        goto fail;
                }
                WL_TRACE(("\n>in %s: apsta set result: %d \n", __FUNCTION__, res));
-#endif 
+#endif
 
                updown = 1;
                if ((res = dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown))) < 0) {
@@ -5725,7 +6311,7 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
                        goto fail;
                }
 
-               res = wl_iw_softap_deassoc_stations(ap_net_dev);
+               res = wl_iw_softap_deassoc_stations(ap_net_dev, NULL);
 
                
                if ((res = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
@@ -5734,12 +6320,37 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
                }
        }
 
+       if (strlen(ap->country_code)) {
+               int error = 0;
+               if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
+                       ap->country_code, sizeof(ap->country_code))) >= 0) {
+                       WL_SOFTAP(("%s: set country %s OK\n",
+                               __FUNCTION__, ap->country_code));
+                       dhd_bus_country_set(dev, &ap->country_code[0]);
+               } else {
+                       WL_ERROR(("%s: ERROR:%d setting country %s\n",
+                               __FUNCTION__, error, ap->country_code));
+               }
+       } else {
+               WL_SOFTAP(("%s: Country code is not specified,"
+                       " will use Radio's default\n",
+                       __FUNCTION__));
+       }
+
+       iolen = wl_bssiovar_mkbuf("closednet",
+               bsscfg_index,  &ap->closednet, sizeof(ap->closednet)+4,
+               buf, sizeof(buf), &mkvar_err);
+       ASSERT(iolen);
+       if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) < 0) {
+               WL_ERROR(("%s failed to set 'closednet'for apsta \n", __FUNCTION__));
+               goto fail;
+       }
+
        
        if ((ap->channel == 0) && (get_softap_auto_channel(dev, ap) < 0)) {
                ap->channel = 1;
                WL_ERROR(("%s auto channel failed, pick up channel=%d\n", \
                        __FUNCTION__, ap->channel));
-
        }
 
        channel = ap->channel;
@@ -5765,7 +6376,6 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
        ap_ssid.SSID_len = strlen(ap->ssid);
        strncpy(ap_ssid.SSID, ap->ssid, ap_ssid.SSID_len);
 
-       
 #ifdef AP_ONLY
        if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
                WL_ERROR(("ERROR:%d in:%s, wl_iw_set_ap_security is skipped\n", \
@@ -5775,7 +6385,6 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
        wl_iw_send_priv_event(dev, "ASCII_CMD=AP_BSS_START");
        ap_cfg_running = TRUE;
 #else
-
        iolen = wl_bssiovar_mkbuf("ssid", bsscfg_index, (char *)(&ap_ssid),
                ap_ssid.SSID_len+4, buf, sizeof(buf), &mkvar_err);
        ASSERT(iolen);
@@ -5785,11 +6394,10 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
                goto fail;
        }
        if (ap_cfg_running == FALSE) {
-               
-               kernel_thread(thr_wait_for_2nd_eth_dev, 0, 0);
+               init_completion(&ap_cfg_exited);
+               ap_cfg_pid = kernel_thread(thr_wait_for_2nd_eth_dev, dev, 0);
        } else {
-
-               
+               ap_cfg_pid = -1;
                if (ap_net_dev == NULL) {
                        WL_ERROR(("%s ERROR: ap_net_dev is NULL !!!\n", __FUNCTION__));
                        goto fail;
@@ -5798,13 +6406,11 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
                WL_ERROR(("%s: %s Configure security & restart AP bss \n", \
                         __FUNCTION__, ap_net_dev->name));
 
-               
                if ((res = wl_iw_set_ap_security(ap_net_dev, &my_ap)) < 0) {
                        WL_ERROR(("%s fail to set security : %d\n", __FUNCTION__, res));
                        goto fail;
                }
 
-               
                if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0) {
                        WL_ERROR(("%s fail to set bss up\n", __FUNCTION__));
                        goto fail;
@@ -5812,11 +6418,10 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
        }
 #endif 
 fail:
-       WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
-       WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_SET);
-       MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
        WL_SOFTAP(("%s exit with %d\n", __FUNCTION__, res));
+
+       net_os_wake_unlock(dev);
+
        return res;
 }
 
@@ -5838,15 +6443,13 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
        WL_SOFTAP(("wl_iw: set ap profile:\n"));
        WL_SOFTAP(("    ssid = '%s'\n", ap->ssid));
        WL_SOFTAP(("    security = '%s'\n", ap->sec));
-       if (ap->key[0] != '\0')
+       if (ap->key[0] != '\0') {
                WL_SOFTAP(("    key = '%s'\n", ap->key));
+       }
        WL_SOFTAP(("    channel = %d\n", ap->channel));
        WL_SOFTAP(("    max scb = %d\n", ap->max_scb));
 
-
        if (strnicmp(ap->sec, "open", strlen("open")) == 0) {
-
-          
                wsec = 0;
                res = dev_wlc_intvar_set(dev, "wsec", wsec);
                wpa_auth = WPA_AUTH_DISABLED;
@@ -5858,7 +6461,6 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
 
        } else if (strnicmp(ap->sec, "wep", strlen("wep")) == 0) {
 
-          
                memset(&key, 0, sizeof(key));
 
                wsec = WEP_ENABLED;
@@ -5885,9 +6487,6 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
                WL_SOFTAP(("=====================\n"));
 
        } else if (strnicmp(ap->sec, "wpa2-psk", strlen("wpa2-psk")) == 0) {
-
-          
-
                wsec_pmk_t psk;
                size_t key_len;
 
@@ -5901,18 +6500,15 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
                        return -1;
                }
 
-               
                if (key_len < WSEC_MAX_PSK_LEN) {
                        unsigned char output[2*SHA1HashSize];
                        char key_str_buf[WSEC_MAX_PSK_LEN+1];
 
-                       
                        memset(output, 0, sizeof(output));
                        pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-                       
+
                        ptr = key_str_buf;
                        for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
-                               
                                sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
                                         (uint)output[i*4+1], (uint)output[i*4+2], \
                                         (uint)output[i*4+3]);
@@ -5934,7 +6530,6 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
 
        } else if (strnicmp(ap->sec, "wpa-psk", strlen("wpa-psk")) == 0) {
 
-               
                wsec_pmk_t psk;
                size_t key_len;
 
@@ -5948,25 +6543,25 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
                        return -1;
                }
 
-               
                if (key_len < WSEC_MAX_PSK_LEN) {
                        unsigned char output[2*SHA1HashSize];
                        char key_str_buf[WSEC_MAX_PSK_LEN+1];
+                       bzero(output, 2*SHA1HashSize);
 
                        WL_SOFTAP(("%s: do passhash...\n", __FUNCTION__));
-                       
+
                        pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-                       
+
                        ptr = key_str_buf;
                        for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
-                               WL_SOFTAP(("[%02d]: %08x\n", i, *((unsigned int*)&output[i*4])));
-                               
-                               sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
-                                       (uint)output[i*4+1], (uint)output[i*4+2], \
-                                        (uint)output[i*4+3]);
+                               WL_SOFTAP(("[%02d]: %08x\n", i, *((unsigned int *)&output[i*4])));
+
+                               sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4],
+                                       (uint)output[i*4+1], (uint)output[i*4+2],
+                                       (uint)output[i*4+3]);
                                ptr += 8;
                        }
-                       printk("%s: passphase = %s\n", __FUNCTION__, key_str_buf);
+                       WL_SOFTAP(("%s: passphase = %s\n", __FUNCTION__, key_str_buf));
 
                        psk.key_len = htod16((ushort)WSEC_MAX_PSK_LEN);
                        memcpy(psk.key, key_str_buf, psk.key_len);
@@ -5998,80 +6593,156 @@ static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
 }
 
 
-static int wl_iw_softap_deassoc_stations(struct net_device *dev)
+
+int get_parmeter_from_string(
+                       char **str_ptr, const char *token,
+                       int param_type, void  *dst, int param_max_len)
+{
+       char int_str[7] = "0";
+       int parm_str_len;
+       char  *param_str_begin;
+       char  *param_str_end;
+
+       if ((*str_ptr) && !strncmp(*str_ptr, token, strlen(token))) {
+
+               strsep(str_ptr, "=,");
+               param_str_begin = *str_ptr;
+               strsep(str_ptr, "=,");
+
+               if (*str_ptr == NULL) {
+                       parm_str_len = strlen(param_str_begin);
+               } else {
+                       param_str_end = *str_ptr-1;
+                       parm_str_len = param_str_end - param_str_begin;
+               }
+
+               WL_TRACE((" 'token:%s', len:%d, ", token, parm_str_len));
+
+               if (parm_str_len > param_max_len) {
+                       WL_TRACE((" WARNING: extracted param len:%d is > MAX:%d\n",
+                               parm_str_len, param_max_len));
+
+                       parm_str_len = param_max_len;
+               }
+
+               switch (param_type) {
+
+               case PTYPE_INTDEC: {
+                       int *pdst_int = dst;
+                       char *eptr;
+
+                       if (parm_str_len > sizeof(int_str))
+                                parm_str_len = sizeof(int_str);
+
+                       memcpy(int_str, param_str_begin, parm_str_len);
+
+                       *pdst_int = simple_strtoul(int_str, &eptr, 10);
+
+                       WL_TRACE((" written as integer:%d\n",  *pdst_int));
+                       }
+                       break;
+               case PTYPE_STR_HEX: {
+                       u8 *buf = dst;
+
+                       param_max_len = param_max_len >> 1;
+                       hstr_2_buf(param_str_begin, buf, param_max_len);
+                       print_buf(buf, param_max_len, 0);
+                       }
+                       break;
+               default:
+                       memcpy(dst, param_str_begin, parm_str_len);
+                       *((char *)dst + parm_str_len) = 0;
+                       WL_TRACE((" written as a string:%s\n", (char *)dst));
+                       break;
+               }
+
+               return 0;
+       } else {
+               WL_ERROR(("\n %s: No token:%s in str:%s\n",
+                       __FUNCTION__, token, *str_ptr));
+
+               return -1;
+       }
+}
+
+static int wl_iw_softap_deassoc_stations(struct net_device *dev, u8 *mac)
 {
        int i;
        int res = 0;
-
        char mac_buf[128] = {0};
+       char z_mac[6] = {0, 0, 0, 0, 0, 0};
+       char *sta_mac;
        struct maclist *assoc_maclist = (struct maclist *) mac_buf;
+       bool deauth_all = false;
+
+       if (mac == NULL) {
+               deauth_all = true;
+               sta_mac = z_mac;
+       } else {
+               sta_mac = mac;
+       }
 
        memset(assoc_maclist, 0, sizeof(mac_buf));
-       assoc_maclist->count = 8; 
+       assoc_maclist->count = 8;
 
        res = dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 128);
        if (res != 0) {
-
-               WL_SOFTAP((" Error:%d in :%s, Couldn't get ASSOC List\n", res, __FUNCTION__));
+               WL_SOFTAP(("%s: Error:%d Couldn't get ASSOC List\n", __FUNCTION__, res));
                return res;
        }
 
-               if (assoc_maclist->count)
-                       for (i = 0; i < assoc_maclist->count; i++) {
+       if (assoc_maclist->count) {
+               for (i = 0; i < assoc_maclist->count; i++) {
                        scb_val_t scbval;
+
                        scbval.val = htod32(1);
-                       
                        bcopy(&assoc_maclist->ea[i], &scbval.ea, ETHER_ADDR_LEN);
 
-                       WL_SOFTAP(("deauth STA:%d \n", i));
-                       res |= dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
-                               &scbval, sizeof(scb_val_t));
-
-               } else WL_SOFTAP((" STA ASSOC list is empty\n"));
-
+                       if (deauth_all || (memcmp(&scbval.ea, sta_mac, ETHER_ADDR_LEN) == 0)) {
+                               WL_SOFTAP(("%s, deauth STA:%d \n", __FUNCTION__, i));
+                               res |= dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
+                                       &scbval, sizeof(scb_val_t));
+                       }
+               }
+       } else {
+               WL_SOFTAP((" STA ASSOC list is empty\n"));
+       }
 
-       if (res != 0)
-               WL_SOFTAP((" Error:%d in :%s\n", res, __FUNCTION__));
-       else if (assoc_maclist->count) {
-               
+       if (res != 0) {
+               WL_ERROR(("%s: Error:%d\n", __FUNCTION__, res));
+       } else if (assoc_maclist->count) {
                bcm_mdelay(200);
        }
        return res;
 }
 
 
-
 static int iwpriv_softap_stop(struct net_device *dev,
        struct iw_request_info *info,
        union iwreq_data *wrqu,
        char *ext)
 {
        int res = 0;
-       wl_iw_t *iw;
 
-       WL_SOFTAP(("got iwpriv AP_BSS_STOP \n"));
+       WL_SOFTAP(("got iwpriv AP_BSS_STOP\n"));
 
        if ((!dev) && (!ap_net_dev)) {
                WL_ERROR(("%s: dev is null\n", __FUNCTION__));
                return res;
        }
 
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK_SOFTAP_SET(iw->pub);
-       WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_STOP, "SoftAP_STOP");
-       WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
+       net_os_wake_lock(dev);
 
-       if  ((ap_cfg_running == TRUE)) {
+       if ((ap_cfg_running == TRUE)) {
 #ifdef AP_ONLY
-                wl_iw_softap_deassoc_stations(dev);
+               wl_iw_softap_deassoc_stations(dev, NULL);
 #else
-                wl_iw_softap_deassoc_stations(ap_net_dev);
+               wl_iw_softap_deassoc_stations(ap_net_dev, NULL);
 
                if ((res = dev_iw_write_cfg1_bss_var(dev, 2)) < 0)
                        WL_ERROR(("%s failed to del BSS err = %d", __FUNCTION__, res));
 #endif
 
-               
                bcm_mdelay(100);
 
                wrqu->data.length = 0;
@@ -6080,25 +6751,22 @@ static int iwpriv_softap_stop(struct net_device *dev,
        else
                WL_ERROR(("%s: was called when SoftAP is OFF : move on\n", __FUNCTION__));
 
-       WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
-       WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_STOP);
-       MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
        WL_SOFTAP(("%s Done with %d\n", __FUNCTION__, res));
+
+       net_os_wake_unlock(dev);
+
        return res;
 }
 
 
-
 static int iwpriv_fw_reload(struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *ext)
+               struct iw_request_info *info,
+               union iwreq_data *wrqu,
+               char *ext)
 {
-
        int ret = -1;
        char extra[256];
-       char *fwstr = fw_path ; 
+       char *fwstr = fw_path;
 
        WL_SOFTAP(("current firmware_path[]=%s\n", fwstr));
 
@@ -6108,7 +6776,6 @@ static int iwpriv_fw_reload(struct net_device *dev,
                                info->cmd, info->flags,
                                wrqu->data.pointer, wrqu->data.length, fwstr, strlen(fwstr)));
 
-
        if ((wrqu->data.length > 4) && (wrqu->data.length < sizeof(extra))) {
 
                char *str_ptr;
@@ -6118,7 +6785,6 @@ static int iwpriv_fw_reload(struct net_device *dev,
                        goto exit_proc;
                }
 
-               
                extra[wrqu->data.length] = 8;
                str_ptr = extra;
 
@@ -6127,9 +6793,9 @@ static int iwpriv_fw_reload(struct net_device *dev,
                        goto exit_proc;
                }
 
-               if  (strstr(fwstr, "apsta") != NULL) {
-                         WL_SOFTAP(("GOT APSTA FIRMWARE\n"));
-                         ap_fw_loaded = TRUE;
+               if (strstr(fwstr, "apsta") != NULL) {
+                       WL_SOFTAP(("GOT APSTA FIRMWARE\n"));
+                       ap_fw_loaded = TRUE;
                } else {
                        WL_SOFTAP(("GOT STA FIRMWARE\n"));
                        ap_fw_loaded = FALSE;
@@ -6144,12 +6810,13 @@ static int iwpriv_fw_reload(struct net_device *dev,
 exit_proc:
        return ret;
 }
-#ifdef SOFTAP
+#endif
 
+#ifdef SOFTAP
 static int iwpriv_wpasupp_loop_tst(struct net_device *dev,
-            struct iw_request_info *info,
-            union iwreq_data *wrqu,
-            char *ext)
+               struct iw_request_info *info,
+               union iwreq_data *wrqu,
+               char *ext)
 {
        int res = 0;
        char  *params = NULL;
@@ -6164,7 +6831,6 @@ static int iwpriv_wpasupp_loop_tst(struct net_device *dev,
                if (!(params = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
                        return -ENOMEM;
 
-
                if (copy_from_user(params, wrqu->data.pointer, wrqu->data.length)) {
                        kfree(params);
                        return -EFAULT;
@@ -6177,148 +6843,163 @@ static int iwpriv_wpasupp_loop_tst(struct net_device *dev,
                return -EFAULT;
        }
 
-       
        res = wl_iw_send_priv_event(dev, params);
        kfree(params);
 
        return res;
 }
-#endif 
+#endif
 
 
 static int
-       iwpriv_en_ap_bss(
+iwpriv_en_ap_bss(
                struct net_device *dev,
                struct iw_request_info *info,
                void *wrqu,
                char *extra)
 {
        int res = 0;
-       wl_iw_t *iw;
 
        if (!dev) {
                WL_ERROR(("%s: dev is null\n", __FUNCTION__));
                return -1;
        }
 
-       WL_TRACE(("%s: rcvd IWPRIV IOCTL:  for dev:%s\n", __FUNCTION__, dev->name));
+       net_os_wake_lock(dev);
 
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK_SOFTAP_SET(iw->pub);
-       WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_START, "SoftAP_START");
-       WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
+       WL_SOFTAP(("%s: rcvd IWPRIV IOCTL:  for dev:%s\n", __FUNCTION__, dev->name));
 
-       
 #ifndef AP_ONLY
+       if (ap_cfg_pid >= 0) {
+               wait_for_completion(&ap_cfg_exited);
+               ap_cfg_pid = -1;
+       }
+
        if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
                WL_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
        }
        else {
-               
                if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0)
                        WL_ERROR(("%s fail to set bss up err=%d\n", __FUNCTION__, res));
                else
-                       
                        bcm_mdelay(100);
        }
 
 #endif 
-
        WL_SOFTAP(("%s done with res %d \n", __FUNCTION__, res));
-       WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
-       WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_START);
-       MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
+
+       net_os_wake_unlock(dev);
+
        return res;
 }
 
 static int
 get_assoc_sta_list(struct net_device *dev, char *buf, int len)
 {
-       
-       WL_TRACE(("calling dev_wlc_ioctl(dev:%p, cmd:%d, buf:%p, len:%d)\n",
-               dev, WLC_GET_ASSOCLIST, buf, len));
+       WL_TRACE(("%s: dev_wlc_ioctl(dev:%p, cmd:%d, buf:%p, len:%d)\n",
+               __FUNCTION__, dev, WLC_GET_ASSOCLIST, buf, len));
 
-       dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, buf, len);
+       return dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, buf, len);
 
-       return 0;
 }
 
 
+void check_error(int res, const char *msg, const char *func, int line)
+{
+       if (res != 0)
+               WL_ERROR(("%s, %d function:%s, line:%d\n", msg, res, func, line));
+}
+
 static int
-set_ap_mac_list(struct net_device *dev, char *buf)
+set_ap_mac_list(struct net_device *dev, void *buf)
 {
        struct mac_list_set *mac_list_set = (struct mac_list_set *)buf;
-       struct maclist *white_maclist = (struct maclist *)&mac_list_set->white_list;
-       struct maclist *black_maclist = (struct maclist *)&mac_list_set->black_list;
-       int mac_mode = mac_list_set->mode;
+       struct maclist *maclist = (struct maclist *)&mac_list_set->mac_list;
        int length;
        int i;
+       int mac_mode = mac_list_set->mode;
+       int ioc_res = 0;
+       ap_macmode = mac_list_set->mode;
+
+       bzero(&ap_black_list, sizeof(struct mflist));
 
-       ap_macmode = mac_mode;
        if (mac_mode == MACLIST_MODE_DISABLED) {
-               
-               bzero(&ap_black_list, sizeof(struct mflist));
 
-               
-               dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+               ioc_res = dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+               check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__);
+               WL_SOFTAP(("%s: MAC filtering disabled\n", __FUNCTION__));
        } else {
+
                scb_val_t scbval;
                char mac_buf[256] = {0};
                struct maclist *assoc_maclist = (struct maclist *) mac_buf;
 
-               mac_mode = MACLIST_MODE_ALLOW;
-               
-               dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+               bcopy(maclist, &ap_black_list, sizeof(ap_black_list));
 
-               
-               length = sizeof(white_maclist->count)+white_maclist->count*ETHER_ADDR_LEN;
-               dev_wlc_ioctl(dev, WLC_SET_MACLIST, white_maclist, length);
-               WL_SOFTAP(("White List, length %d:\n", length));
-               for (i = 0; i < white_maclist->count; i++)
-                       WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
-                               i, white_maclist->ea[i].octet[0], white_maclist->ea[i].octet[1], \
-                               white_maclist->ea[i].octet[2], \
-                               white_maclist->ea[i].octet[3], white_maclist->ea[i].octet[4], \
-                               white_maclist->ea[i].octet[5]));
+               ioc_res = dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
+               check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__);
 
-               
-               bcopy(black_maclist, &ap_black_list, sizeof(ap_black_list));
+               length = sizeof(maclist->count) + maclist->count*ETHER_ADDR_LEN;
+               dev_wlc_ioctl(dev, WLC_SET_MACLIST, maclist, length);
 
-               WL_SOFTAP(("Black List, size %d:\n", sizeof(ap_black_list)));
-               for (i = 0; i < ap_black_list.count; i++)
+               WL_SOFTAP(("%s: applied MAC List, mode:%d, length %d:\n",
+                       __FUNCTION__, mac_mode, length));
+               for (i = 0; i < maclist->count; i++)
                        WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
-                               i, ap_black_list.ea[i].octet[0], ap_black_list.ea[i].octet[1], \
-                               ap_black_list.ea[i].octet[2], \
-                               ap_black_list.ea[i].octet[3], \
-                               ap_black_list.ea[i].octet[4], ap_black_list.ea[i].octet[5]));
+                               i, maclist->ea[i].octet[0], maclist->ea[i].octet[1], \
+                               maclist->ea[i].octet[2], \
+                               maclist->ea[i].octet[3], maclist->ea[i].octet[4], \
+                               maclist->ea[i].octet[5]));
 
-               
-               dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 256);
-               if (assoc_maclist->count) {
-                       int j;
+               assoc_maclist->count = 8;
+               ioc_res = dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 256);
+               check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__);
+               WL_SOFTAP((" Cur assoc clients:%d\n", assoc_maclist->count));
+
+               if (assoc_maclist->count)
                        for (i = 0; i < assoc_maclist->count; i++) {
-                               for (j = 0; j < white_maclist->count; j++) {
-                                       if (!bcmp(&assoc_maclist->ea[i], &white_maclist->ea[j], \
+                               int j;
+                               bool assoc_mac_matched = false;
+
+                               WL_SOFTAP(("\n Cheking assoc STA: "));
+                               print_buf(&assoc_maclist->ea[i], 6, 7);
+                               WL_SOFTAP(("with the b/w list:"));
+
+                               for (j = 0; j < maclist->count; j++)
+                                       if (!bcmp(&assoc_maclist->ea[i], &maclist->ea[j],
                                                ETHER_ADDR_LEN)) {
-                                               WL_SOFTAP(("match allow, let it be\n"));
+
+                                               assoc_mac_matched = true;
                                                break;
                                        }
+
+                               if (((mac_mode == MACLIST_MODE_ALLOW) && !assoc_mac_matched) ||
+                                       ((mac_mode == MACLIST_MODE_DENY) && assoc_mac_matched)) {
+
+                                       WL_SOFTAP(("b-match or w-mismatch,"
+                                                               " do deauth/disassoc \n"));
+                                                       scbval.val = htod32(1);
+                                                       bcopy(&assoc_maclist->ea[i], &scbval.ea, \
+                                                       ETHER_ADDR_LEN);
+                                                       ioc_res = dev_wlc_ioctl(dev,
+                                                               WLC_SCB_DEAUTHENTICATE_FOR_REASON,
+                                                               &scbval, sizeof(scb_val_t));
+                                                       check_error(ioc_res,
+                                                               "ioctl ERROR:",
+                                                               __FUNCTION__, __LINE__);
+
+                               } else {
+                                       WL_SOFTAP((" no b/w list hits, let it be\n"));
                                }
-                               if (j == white_maclist->count) {
-                                               WL_SOFTAP(("match black, deauth it\n"));
-                                               scbval.val = htod32(1);
-                                               bcopy(&assoc_maclist->ea[i], &scbval.ea, \
-                                               ETHER_ADDR_LEN);
-                                               dev_wlc_ioctl(dev, \
-                                                       WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
-                                                       sizeof(scb_val_t));
-                               }
-                       }
+               } else {
+                       WL_SOFTAP(("No ASSOC CLIENTS\n"));
                }
-       }
-       return 0;
+       } 
+
+       WL_SOFTAP(("%s iocres:%d\n", __FUNCTION__, ioc_res));
+       return ioc_res;
 }
-#endif /* SOFTAP */
+#endif
 
 
 #ifdef SOFTAP
@@ -6348,10 +7029,10 @@ int wl_iw_process_private_ascii_cmd(
 
                WL_SOFTAP((" AP_CFG \n"));
 
-               
+
                if (init_ap_profile_from_string(cmd_str+PROFILE_OFFSET, &my_ap) != 0) {
-                               WL_ERROR(("ERROR: SoftAP CFG prams !\n"));
-                               ret = -1;
+                       WL_ERROR(("ERROR: SoftAP CFG prams !\n"));
+                       ret = -1;
                } else {
                        ret = set_ap_cfg(dev, &my_ap);
                }
@@ -6360,14 +7041,12 @@ int wl_iw_process_private_ascii_cmd(
 
                WL_SOFTAP(("\n SOFTAP - ENABLE BSS \n"));
 
-               
                WL_SOFTAP(("\n!!! got 'WL_AP_EN_BSS' from WPA supplicant, dev:%s\n", dev->name));
 
 #ifndef AP_ONLY
                if (ap_net_dev == NULL) {
-                                printf("\n ERROR: SOFTAP net_dev* is NULL !!!\n");
+                       printf("\n ERROR: SOFTAP net_dev* is NULL !!!\n");
                } else {
-                         
                        if ((ret = iwpriv_en_ap_bss(ap_net_dev, info, dwrq, cmd_str)) < 0)
                                WL_ERROR(("%s line %d fail to set bss up\n", \
                                        __FUNCTION__, __LINE__));
@@ -6378,11 +7057,8 @@ int wl_iw_process_private_ascii_cmd(
                                        __FUNCTION__, __LINE__));
 #endif
        } else if (strnicmp(sub_cmd, "ASSOC_LST", strlen("ASSOC_LST")) == 0) {
-
-               
-
+               /* no code yet */
        } else if (strnicmp(sub_cmd, "AP_BSS_STOP", strlen("AP_BSS_STOP")) == 0) {
-
                WL_SOFTAP((" \n temp DOWN SOFTAP\n"));
 #ifndef AP_ONLY
                if ((ret = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
@@ -6393,9 +7069,33 @@ int wl_iw_process_private_ascii_cmd(
        }
 
        return ret;
+}
+#endif
+
+#define BCM4329_WAKELOCK_NAME "bcm4329_wifi_wakelock"
 
+static struct wake_lock bcm4329_suspend_lock;
+
+int bcm4329_wakelock_init = 0;
+
+void bcm4329_power_save_init(void)
+{
+        wake_lock_init(&bcm4329_suspend_lock, WAKE_LOCK_SUSPEND, BCM4329_WAKELOCK_NAME);
+        wake_lock(&bcm4329_suspend_lock);
+        
+       bcm4329_wakelock_init = 2;
 }
-#endif 
+
+void bcm4329_power_save_exit(void)
+{
+        bcm4329_wakelock_init = 0;
+        msleep(100);
+        
+       if (bcm4329_wakelock_init == 2)
+                wake_unlock(&bcm4329_suspend_lock);
+        wake_lock_destroy(&bcm4329_suspend_lock);
+}
+
 static int wl_iw_set_priv(
        struct net_device *dev,
        struct iw_request_info *info,
@@ -6406,7 +7106,6 @@ static int wl_iw_set_priv(
        int ret = 0;
        char * extra;
 
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
        if (!(extra = kmalloc(dwrq->length, GFP_KERNEL)))
            return -ENOMEM;
 
@@ -6415,95 +7114,120 @@ static int wl_iw_set_priv(
            return -EFAULT;
        }
 
-       WL_TRACE(("%s: SIOCSIWPRIV request %s, info->cmd:%x, info->flags:%d\n dwrq->length:%d\n",
+       WL_TRACE(("%s: SIOCSIWPRIV request %s, info->cmd:%x, info->flags:%d\n dwrq->length:%d",
                dev->name, extra, info->cmd, info->flags, dwrq->length));
 
+       net_os_wake_lock(dev);
        
        if (dwrq->length && extra) {
-               WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_PRIV, "wl_iw_set_priv");
-               WAKE_LOCK(iw->pub, WAKE_LOCK_PRIV);
+               if (strnicmp(extra, "START", strlen("START")) == 0) {
+                       if (bcm4329_wakelock_init == 1)
+                        {
+                                wake_lock(&bcm4329_suspend_lock);
+                                bcm4329_wakelock_init = 2;
+                        }
+                       wl_iw_control_wl_on(dev, info);
+                       WL_TRACE(("%s, Received regular START command\n", __FUNCTION__));
+               }
 
                if (g_onoff == G_WLAN_SET_OFF) {
-                       if (strnicmp(extra, "START", strlen("START")) != 0) {
-                                       WL_ERROR(("%s First IOCTL after stop is NOT START \n", \
-                                                               __FUNCTION__));
-                               WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
-                               WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
-                               kfree(extra);
-                               return -EFAULT;
-                       } else {
-                               wl_iw_control_wl_on(dev, info);
-                               WL_TRACE(("%s, Received regular START command\n", __FUNCTION__));
-                       }
+                       WL_TRACE(("%s, missing START, Fail\n", __FUNCTION__));
+                       kfree(extra);
+                       net_os_wake_unlock(dev);
+                       return -EFAULT;
                }
 
-           if (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
+               if (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
 #ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
                        WL_TRACE(("%s: active scan setting suppressed\n", dev->name));
 #else
                        ret = wl_iw_set_active_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif 
-           }
-           else if (strnicmp(extra, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0)
+#endif
+               } else if (strnicmp(extra, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0)
 #ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
                        WL_TRACE(("%s: passive scan setting suppressed\n", dev->name));
 #else
                        ret = wl_iw_set_passive_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif 
-           else if (strnicmp(extra, "RSSI", strlen("RSSI")) == 0)
+#endif
+               else if (strnicmp(extra, "RSSI", strlen("RSSI")) == 0)
                        ret = wl_iw_get_rssi(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "LINKSPEED", strlen("LINKSPEED")) == 0)
+               else if (strnicmp(extra, "LINKSPEED", strlen("LINKSPEED")) == 0)
                        ret = wl_iw_get_link_speed(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "MACADDR", strlen("MACADDR")) == 0)
+               else if (strnicmp(extra, "MACADDR", strlen("MACADDR")) == 0)
                        ret = wl_iw_get_macaddr(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "COUNTRY", strlen("COUNTRY")) == 0)
+               else if (strnicmp(extra, "COUNTRY", strlen("COUNTRY")) == 0)
                        ret = wl_iw_set_country(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "STOP", strlen("STOP")) == 0)
+               else if (strnicmp(extra, "SCAN-CHANNELS", strlen("SCAN-CHANNELS")) == 0)
+                       ret = wl_iw_get_country(dev, info, (union iwreq_data *)dwrq, extra);
+               else if (strnicmp(extra, "STOP", strlen("STOP")) == 0){
                        ret = wl_iw_control_wl_off(dev, info);
-           else if (strnicmp(extra, BAND_GET_CMD, strlen(BAND_GET_CMD)) == 0)
+                       if (bcm4329_wakelock_init == 2)
+                        {
+                                wake_unlock(&bcm4329_suspend_lock);
+                                bcm4329_wakelock_init = 1;
+                        }
+               }
+               else if (strnicmp(extra, BAND_GET_CMD, strlen(BAND_GET_CMD)) == 0)
                        ret = wl_iw_get_band(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, BAND_SET_CMD, strlen(BAND_SET_CMD)) == 0)
+               else if (strnicmp(extra, BAND_SET_CMD, strlen(BAND_SET_CMD)) == 0)
                        ret = wl_iw_set_band(dev, info, (union iwreq_data *)dwrq, extra);
+               else if (strnicmp(extra, DTIM_SKIP_GET_CMD, strlen(DTIM_SKIP_GET_CMD)) == 0)
+                       ret = wl_iw_get_dtim_skip(dev, info, (union iwreq_data *)dwrq, extra);
+               else if (strnicmp(extra, DTIM_SKIP_SET_CMD, strlen(DTIM_SKIP_SET_CMD)) == 0)
+                       ret = wl_iw_set_dtim_skip(dev, info, (union iwreq_data *)dwrq, extra);
+               else if (strnicmp(extra, SETSUSPEND_CMD, strlen(SETSUSPEND_CMD)) == 0)
+                       ret = wl_iw_set_suspend(dev, info, (union iwreq_data *)dwrq, extra);
+#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
+               else if (strnicmp(extra, SETDFSCHANNELS_CMD, strlen(SETDFSCHANNELS_CMD)) == 0)
+                       ret = wl_iw_set_dfs_channels(dev, info, (union iwreq_data *)dwrq, extra);
+#endif
+#if defined(PNO_SUPPORT)
+               else if (strnicmp(extra, PNOSSIDCLR_SET_CMD, strlen(PNOSSIDCLR_SET_CMD)) == 0)
+                       ret = wl_iw_set_pno_reset(dev, info, (union iwreq_data *)dwrq, extra);
+               else if (strnicmp(extra, PNOSETUP_SET_CMD, strlen(PNOSETUP_SET_CMD)) == 0)
+                       ret = wl_iw_set_pno_set(dev, info, (union iwreq_data *)dwrq, extra);
+               else if (strnicmp(extra, PNOENABLE_SET_CMD, strlen(PNOENABLE_SET_CMD)) == 0)
+                       ret = wl_iw_set_pno_enable(dev, info, (union iwreq_data *)dwrq, extra);
+#endif
 #if defined(CSCAN)
-           
            else if (strnicmp(extra, CSCAN_COMMAND, strlen(CSCAN_COMMAND)) == 0)
                        ret = wl_iw_set_cscan(dev, info, (union iwreq_data *)dwrq, extra);
 #endif 
 #ifdef CUSTOMER_HW2
-           else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
+               else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
                        ret = wl_iw_set_power_mode(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0)
+               else if (strnicmp(extra, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0)
                        ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
 #else
-           else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
+               else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
                        ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
 #endif
+               else if (strnicmp(extra, "GETPOWER", strlen("GETPOWER")) == 0)
+                       ret = wl_iw_get_power_mode(dev, info, (union iwreq_data *)dwrq, extra);
 #ifdef SOFTAP
-           else if (strnicmp(extra, "ASCII_CMD", strlen("ASCII_CMD")) == 0) {
-               
-                   wl_iw_process_private_ascii_cmd(dev, info, (union iwreq_data *)dwrq, extra);
-           }
-               else if (strnicmp(extra, "AP_MAC_LIST_SET", strlen("AP_MAC_LIST_SET")) == 0) {
+               else if (strnicmp(extra, "ASCII_CMD", strlen("ASCII_CMD")) == 0) {
+                       wl_iw_process_private_ascii_cmd(dev, info, (union iwreq_data *)dwrq, extra);
+               } else if (strnicmp(extra, "AP_MAC_LIST_SET", strlen("AP_MAC_LIST_SET")) == 0) {
                        WL_SOFTAP(("penguin, set AP_MAC_LIST_SET\n"));
                        set_ap_mac_list(dev, (extra + PROFILE_OFFSET));
-           }
-#endif 
-           else {
-                       WL_TRACE(("Unkown PRIVATE command %s\n", extra));
+               }
+#endif
+               else {
+                       WL_TRACE(("Unknown PRIVATE command: %s: ignored\n", extra));
                        snprintf(extra, MAX_WX_STRING, "OK");
                        dwrq->length = strlen("OK") + 1;
                }
-               WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
-               WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
        }
 
+       net_os_wake_unlock(dev);
+
        if (extra) {
-           if (copy_to_user(dwrq->pointer, extra, dwrq->length)) {
+               if (copy_to_user(dwrq->pointer, extra, dwrq->length)) {
                        kfree(extra);
                        return -EFAULT;
-           }
+               }
 
-           kfree(extra);
+               kfree(extra);
        }
 
        return ret;
@@ -6519,12 +7243,12 @@ static const iw_handler wl_iw_handler[] =
        (iw_handler) wl_iw_get_freq,            
        (iw_handler) wl_iw_set_mode,            
        (iw_handler) wl_iw_get_mode,            
-       (iw_handler) wl_iw_set_sens,
-       (iw_handler) wl_iw_get_sens,
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_get_range,           
-       (iw_handler) wl_iw_set_priv,            
-       (iw_handler) NULL,                      
+       (iw_handler) NULL,
+       (iw_handler) NULL,
+       (iw_handler) NULL,
+       (iw_handler) wl_iw_get_range,
+       (iw_handler) wl_iw_set_priv,
+       (iw_handler) NULL,
        (iw_handler) NULL,                      
        (iw_handler) NULL,                      
        (iw_handler) wl_iw_set_spy,             
@@ -6557,7 +7281,7 @@ static const iw_handler wl_iw_handler[] =
 #endif 
        (iw_handler) wl_iw_set_essid,           
        (iw_handler) wl_iw_get_essid,           
-       (iw_handler) wl_iw_set_nick,            
+       (iw_handler) wl_iw_set_nick,
        (iw_handler) wl_iw_get_nick,            
        (iw_handler) NULL,                      
        (iw_handler) NULL,                      
@@ -6608,45 +7332,40 @@ static const iw_handler wl_iw_priv_handler[] = {
        (iw_handler)wl_iw_control_wl_off,
        NULL,
        (iw_handler)wl_iw_control_wl_on,
-#ifdef SOFTAP       
-
-       
+#ifdef SOFTAP
        NULL,
        (iw_handler)iwpriv_set_ap_config,
 
-       
-       
        NULL,
        (iw_handler)iwpriv_get_assoc_list,
 
-       
        NULL,
        (iw_handler)iwpriv_set_mac_filters,
 
-       
        NULL,
        (iw_handler)iwpriv_en_ap_bss,
 
-       
        NULL,
        (iw_handler)iwpriv_wpasupp_loop_tst,
-       
+
        NULL,
        (iw_handler)iwpriv_softap_stop,
-       
+
        NULL,
        (iw_handler)iwpriv_fw_reload,
-#endif 
+
+       NULL,
+       (iw_handler)iwpriv_set_ap_sta_disassoc,
+#endif
 #if defined(CSCAN)
-       
+
        NULL,
        (iw_handler)iwpriv_set_cscan
 #endif         
 };
 
-static const struct iw_priv_args wl_iw_priv_args[] =
-{
-       {       
+static const struct iw_priv_args wl_iw_priv_args[] = {
+       {
                WL_IW_SET_ACTIVE_SCAN,
                0,
                IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
@@ -6690,30 +7409,28 @@ static const struct iw_priv_args wl_iw_priv_args[] =
        },
 
 #ifdef SOFTAP
-       
-       
        {
                WL_SET_AP_CFG,
-               IW_PRIV_TYPE_CHAR |  256,      
+               IW_PRIV_TYPE_CHAR |  256,
                0,
                "AP_SET_CFG"
        },
 
        {
                WL_AP_STA_LIST,
-               0,                     
-               IW_PRIV_TYPE_CHAR | 0, 
+               IW_PRIV_TYPE_CHAR | 0,
+               IW_PRIV_TYPE_CHAR | 1024,
                "AP_GET_STA_LIST"
        },
 
        {
                WL_AP_MAC_FLTR,
-               IW_PRIV_TYPE_CHAR | 256,                      
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,    
+               IW_PRIV_TYPE_CHAR | 256,
+               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
                "AP_SET_MAC_FLTR"
        },
 
-       { 
+       {
                WL_AP_BSS_START,
                0,
                IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
@@ -6722,33 +7439,41 @@ static const struct iw_priv_args wl_iw_priv_args[] =
 
        {
                AP_LPB_CMD,
-               IW_PRIV_TYPE_CHAR | 256,   
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,    
+               IW_PRIV_TYPE_CHAR | 256,
+               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
                "AP_LPB_CMD"
        },
 
-       { 
+       {
                WL_AP_STOP,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,   
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,   
+               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
+               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
                "AP_BSS_STOP"
        },
-       { 
+
+       {
                WL_FW_RELOAD,
                IW_PRIV_TYPE_CHAR | 256,
                IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
                "WL_FW_RELOAD"
        },
-#endif 
+
+       {
+               WL_AP_STA_DISASSOC,
+               IW_PRIV_TYPE_CHAR | 256,
+               IW_PRIV_TYPE_CHAR | 0,
+               "AP_STA_DISASSOC"
+       },
+#endif
 #if defined(CSCAN)
-       { 
+       {
                WL_COMBO_SCAN,
-               IW_PRIV_TYPE_CHAR | 1024,  
+               IW_PRIV_TYPE_CHAR | 1024,
                0,
                "CSCAN"
        },
-#endif 
-       };
+#endif
+};
 
 const struct iw_handler_def wl_iw_handler_def =
 {
@@ -6762,11 +7487,10 @@ const struct iw_handler_def wl_iw_handler_def =
 #if WIRELESS_EXT >= 19
        get_wireless_stats: dhd_get_wireless_stats,
 #endif 
-       };
+};
 #endif 
 
 
-
 int wl_iw_ioctl(
        struct net_device *dev,
        struct ifreq *rq,
@@ -6779,11 +7503,14 @@ int wl_iw_ioctl(
        char *extra = NULL;
        int token_size = 1, max_tokens = 0, ret = 0;
 
-       WL_TRACE(("\n%s, cmd:%x alled via dhd->do_ioctl()entry point\n", __FUNCTION__, cmd));
+       net_os_wake_lock(dev);
+
+       WL_TRACE(("%s: cmd:%x alled via dhd->do_ioctl()entry point\n", __FUNCTION__, cmd));
        if (cmd < SIOCIWFIRST ||
                IW_IOCTL_IDX(cmd) >= ARRAYSIZE(wl_iw_handler) ||
                !(handler = wl_iw_handler[IW_IOCTL_IDX(cmd)])) {
                        WL_ERROR(("%s: error in cmd=%x : not supported\n", __FUNCTION__, cmd));
+                       net_os_wake_unlock(dev);
                        return -EOPNOTSUPP;
        }
 
@@ -6806,7 +7533,6 @@ int wl_iw_ioctl(
                break;
 
        case SIOCGIWRANGE:
-               
                max_tokens = sizeof(struct iw_range) + 500;
                break;
 
@@ -6849,14 +7575,18 @@ int wl_iw_ioctl(
                if (wrq->u.data.length > max_tokens) {
                        WL_ERROR(("%s: error in cmd=%x wrq->u.data.length=%d  > max_tokens=%d\n", \
                                __FUNCTION__, cmd, wrq->u.data.length, max_tokens));
-                       return -E2BIG;
+                       ret = -E2BIG;
+                       goto wl_iw_ioctl_done;
+               }
+               if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL))) {
+                       ret = -ENOMEM;
+                       goto wl_iw_ioctl_done;
                }
-               if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL)))
-                       return -ENOMEM;
 
                if (copy_from_user(extra, wrq->u.data.pointer, wrq->u.data.length * token_size)) {
                        kfree(extra);
-                       return -EFAULT;
+                       ret = -EFAULT;
+                       goto wl_iw_ioctl_done;
                }
        }
 
@@ -6868,12 +7598,17 @@ int wl_iw_ioctl(
        if (extra) {
                if (copy_to_user(wrq->u.data.pointer, extra, wrq->u.data.length * token_size)) {
                        kfree(extra);
-                       return -EFAULT;
+                       ret = -EFAULT;
+                       goto wl_iw_ioctl_done;
                }
 
                kfree(extra);
        }
 
+wl_iw_ioctl_done:
+
+       net_os_wake_unlock(dev);
+
        return ret;
 }
 
@@ -6972,11 +7707,11 @@ wl_iw_check_conn_fail(wl_event_msg_t *e, char* stringBuf, uint buflen)
        else
                return FALSE;
 }
-#endif 
+#endif
 
 #ifndef IW_CUSTOM_MAX
 #define IW_CUSTOM_MAX 256 
-#endif 
+#endif
 
 void
 wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
@@ -6989,24 +7724,29 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
        uint16 flags =  ntoh16(e->flags);
        uint32 datalen = ntoh32(e->datalen);
        uint32 status =  ntoh32(e->status);
-       wl_iw_t *iw;
        uint32 toto;
+       static uint32 roam_no_success = 0;
+       static bool roam_no_success_send = FALSE;
 
        memset(&wrqu, 0, sizeof(wrqu));
        memset(extra, 0, sizeof(extra));
-       iw = 0;
 
        if (!dev) {
                WL_ERROR(("%s: dev is null\n", __FUNCTION__));
                return;
        }
 
-       iw = *(wl_iw_t **)netdev_priv(dev);
+       net_os_wake_lock(dev);
 
-       //WL_TRACE(("%s: dev=%s event=%d \n", __FUNCTION__, dev->name, event_type));
+       WL_TRACE(("%s: dev=%s event=%d \n", __FUNCTION__, dev->name, event_type));
 
-       
        switch (event_type) {
+
+       case WLC_E_RELOAD:
+               WL_ERROR(("%s: Firmware ERROR %d\n", __FUNCTION__, status));
+               net_os_send_hang_message(dev);
+               goto wl_iw_event_end;
+
 #if defined(SOFTAP)
        case WLC_E_PRUNE:
                if (ap_cfg_running) {
@@ -7015,9 +7755,7 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                                macaddr[0], macaddr[1], macaddr[2], macaddr[3], \
                                macaddr[4], macaddr[5]));
 
-                       
-                       if (ap_macmode)
-                       {
+                       if (ap_macmode) {
                                int i;
                                for (i = 0; i < ap_black_list.count; i++) {
                                        if (!bcmp(macaddr, &ap_black_list.ea[i], \
@@ -7028,7 +7766,6 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                                }
 
                                if (i == ap_black_list.count) {
-                                       
                                        char mac_buf[32] = {0};
                                        sprintf(mac_buf, "STA_BLOCK %02X:%02X:%02X:%02X:%02X:%02X",
                                                macaddr[0], macaddr[1], macaddr[2],
@@ -7038,7 +7775,7 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                        }
                }
                break;
-#endif 
+#endif
        case WLC_E_TXFAIL:
                cmd = IWEVTXDROP;
                memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
@@ -7052,22 +7789,43 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                WL_SOFTAP(("STA connect received %d\n", event_type));
                if (ap_cfg_running) {
                        wl_iw_send_priv_event(priv_dev, "STA_JOIN");
-                       return;
+                       goto wl_iw_event_end;
                }
-#endif 
+#endif
                memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
                wrqu.addr.sa_family = ARPHRD_ETHER;
                cmd = IWEVREGISTERED;
                break;
+       case WLC_E_ROAM:
+               if (status == WLC_E_STATUS_SUCCESS) {
+                       memcpy(wrqu.addr.sa_data, &e->addr.octet, ETHER_ADDR_LEN);
+                       wrqu.addr.sa_family = ARPHRD_ETHER;
+                       cmd = SIOCGIWAP;
+               }
+               else if (status == WLC_E_STATUS_NO_NETWORKS) {
+                       roam_no_success++;
+                       if ((roam_no_success == 5) && (roam_no_success_send == FALSE)) {
+                               roam_no_success_send = TRUE;
+                               bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
+                               bzero(&extra, ETHER_ADDR_LEN);
+                               cmd = SIOCGIWAP;
+                               WL_ERROR(("%s  ROAMING did not succeeded , send Link Down\n", \
+                                       __FUNCTION__));
+                       } else {
+                               WL_TRACE(("##### ROAMING did not succeeded %d\n", roam_no_success));
+                               goto wl_iw_event_end;
+                       }
+               }
+               break;
        case WLC_E_DEAUTH_IND:
        case WLC_E_DISASSOC_IND:
 #if defined(SOFTAP)
                WL_SOFTAP(("STA disconnect received %d\n", event_type));
                if (ap_cfg_running) {
                        wl_iw_send_priv_event(priv_dev, "STA_LEAVE");
-                       return;
+                       goto wl_iw_event_end;
                }
-#endif 
+#endif
                cmd = SIOCGIWAP;
                bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
                wrqu.addr.sa_family = ARPHRD_ETHER;
@@ -7077,54 +7835,50 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
        case WLC_E_NDIS_LINK:
                cmd = SIOCGIWAP;
                if (!(flags & WLC_EVENT_MSG_LINK)) {
-                       
-                       
 #ifdef SOFTAP
 #ifdef AP_ONLY
                if (ap_cfg_running) {
 #else
                if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
 #endif 
-                       
-                       WL_SOFTAP(("AP DOWN %d\n", event_type));
-                       wl_iw_send_priv_event(priv_dev, "AP_DOWN");
-               } else {
-                       WL_TRACE(("STA_Link Down\n"));
+                               WL_SOFTAP(("AP DOWN %d\n", event_type));
+                               wl_iw_send_priv_event(priv_dev, "AP_DOWN");
+                       } else {
+                               WL_TRACE(("STA_Link Down\n"));
+                               g_ss_cache_ctrl.m_link_down = 1;
+                       }
+#else
                        g_ss_cache_ctrl.m_link_down = 1;
-               }
-#else          
-               g_ss_cache_ctrl.m_link_down = 1;
-#endif 
+#endif
                        WL_TRACE(("Link Down\n"));
 
                        bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
                        bzero(&extra, ETHER_ADDR_LEN);
-                       WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_LINK_DOWN_TMOUT, 20 * HZ);
                }
                else {
-                       
                        memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
                        g_ss_cache_ctrl.m_link_down = 0;
-                       
+
                        memcpy(g_ss_cache_ctrl.m_active_bssid, &e->addr, ETHER_ADDR_LEN);
-#ifdef SOFTAP
 
+#ifdef SOFTAP
 #ifdef AP_ONLY
                        if (ap_cfg_running) {
 #else
                        if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
 #endif
-                       
                                WL_SOFTAP(("AP UP %d\n", event_type));
                                wl_iw_send_priv_event(priv_dev, "AP_UP");
                        } else {
                                WL_TRACE(("STA_LINK_UP\n"));
+                               roam_no_success_send = FALSE;
+                               roam_no_success = 0;
                        }
-#else
-#endif 
+#endif
                        WL_TRACE(("Link UP\n"));
 
                }
+               net_os_wake_lock_timeout_enable(dev);
                wrqu.addr.sa_family = ARPHRD_ETHER;
                break;
        case WLC_E_ACTION_FRAME:
@@ -7191,7 +7945,7 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                                count--;
                        }
                }
-               return;
+               goto wl_iw_event_end;
        }
 #endif 
 #endif 
@@ -7212,7 +7966,21 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                cmd = SIOCGIWSCAN;
                wrqu.data.length = strlen(extra);
                WL_TRACE(("Event WLC_E_SCAN_COMPLETE\n"));
-#endif 
+#endif
+               break;
+
+       case WLC_E_PFN_NET_FOUND:
+       {
+               wlc_ssid_t      * ssid;
+               ssid = (wlc_ssid_t *)data;
+               WL_TRACE(("%s Event WLC_E_PFN_NET_FOUND, send %s up : find %s len=%d\n", \
+                       __FUNCTION__, PNO_EVENT_UP, ssid->SSID, ssid->SSID_len));
+               net_os_wake_lock_timeout_enable(dev);
+               cmd = IWEVCUSTOM;
+               memset(&wrqu, 0, sizeof(wrqu));
+               strcpy(extra, PNO_EVENT_UP);
+               wrqu.data.length = strlen(extra);
+       }
        break;
 
        default:
@@ -7221,12 +7989,14 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                break;
        }
 #ifndef SANDGATE2G
-               if (cmd) {
-                       if (cmd == SIOCGIWSCAN)
-                               wireless_send_event(dev, cmd, &wrqu, NULL);
-                       else
-                               wireless_send_event(dev, cmd, &wrqu, extra);
-               }
+       if (cmd) {
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 31))
+               if (cmd == SIOCGIWSCAN)
+                       wireless_send_event(dev, cmd, &wrqu, NULL);
+               else
+#endif
+               wireless_send_event(dev, cmd, &wrqu, extra);
+       }
 #endif
 
 #if WIRELESS_EXT > 14
@@ -7239,9 +8009,10 @@ wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
                wireless_send_event(dev, cmd, &wrqu, extra);
 #endif
        }
-#endif 
-
-#endif 
+#endif
+wl_iw_event_end:
+       net_os_wake_unlock(dev);
+#endif
 }
 
 int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
@@ -7332,23 +8103,30 @@ wl_iw_bt_flag_set(
        struct net_device *dev,
        bool set)
 {
+#if defined(BT_DHCP_USE_FLAGS)
        char buf_flag7_dhcp_on[8] = { 7, 00, 00, 00, 0x1, 0x0, 0x00, 0x00 };
        char buf_flag7_default[8]   = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
+#endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        rtnl_lock();
 #endif
 
+#if defined(BT_DHCP_eSCO_FIX)
+       set_btc_esco_params(dev, set);
+#endif
+
+#if defined(BT_DHCP_USE_FLAGS)
+       WL_TRACE_COEX(("WI-FI priority boost via bt flags, set:%d\n", set));
        if (set == TRUE) {
-               
-               dev_wlc_bufvar_set(dev, "btc_flags", \
+               dev_wlc_bufvar_set(dev, "btc_flags",
                                        (char *)&buf_flag7_dhcp_on[0], sizeof(buf_flag7_dhcp_on));
        }
        else  {
-               
-               dev_wlc_bufvar_set(dev, "btc_flags", \
+               dev_wlc_bufvar_set(dev, "btc_flags",
                                        (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
        }
+#endif
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
        rtnl_unlock();
@@ -7361,7 +8139,7 @@ wl_iw_bt_timerfunc(ulong data)
        bt_info_t  *bt_local = (bt_info_t *)data;
        bt_local->timer_on = 0;
        WL_TRACE(("%s\n", __FUNCTION__));
-       
+
        up(&bt_local->bt_sem);
 }
 
@@ -7371,37 +8149,53 @@ _bt_dhcp_sysioc_thread(void *data)
        DAEMONIZE("dhcp_sysioc");
 
        while (down_interruptible(&g_bt->bt_sem) == 0) {
+
+               net_os_wake_lock(g_bt->dev);
+
                if (g_bt->timer_on) {
-                       del_timer(&g_bt->timer);
                        g_bt->timer_on = 0;
+                       del_timer_sync(&g_bt->timer);
                }
 
                switch (g_bt->bt_state) {
                        case BT_DHCP_START:
-                               
+                               WL_TRACE_COEX(("%s bt_dhcp stm: started \n", __FUNCTION__));
                                g_bt->bt_state = BT_DHCP_OPPORTUNITY_WINDOW;
-                               mod_timer(&g_bt->timer, jiffies + \
-                                          BT_DHCP_OPPORTUNITY_WINDOW_TIEM*HZ/1000);
+                               mod_timer(&g_bt->timer, jiffies + BT_DHCP_OPPORTUNITY_WINDOW_TIME*HZ/1000);
                                g_bt->timer_on = 1;
                                break;
+
                        case BT_DHCP_OPPORTUNITY_WINDOW:
-                               
-                               WL_TRACE(("%s waiting for %d msec expired, force bt flag\n", \
-                                               __FUNCTION__, BT_DHCP_OPPORTUNITY_WINDOW_TIEM));
+                               if (g_bt->dhcp_done) {
+                                       WL_TRACE_COEX(("%s DHCP Done before T1 expiration\n", \
+                                               __FUNCTION__));
+                                       g_bt->bt_state = BT_DHCP_IDLE;
+                                       g_bt->timer_on = 0;
+                                       break;
+                               }
+
+                               WL_TRACE_COEX(("%s DHCP T1:%d expired\n", \
+                                               __FUNCTION__, BT_DHCP_OPPORTUNITY_WINDOW_TIME));
                                if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, TRUE);
                                g_bt->bt_state = BT_DHCP_FLAG_FORCE_TIMEOUT;
                                mod_timer(&g_bt->timer, jiffies + BT_DHCP_FLAG_FORCE_TIME*HZ/1000);
                                g_bt->timer_on = 1;
                                break;
+
                        case BT_DHCP_FLAG_FORCE_TIMEOUT:
-                               
-                               WL_TRACE(("%s waiting for %d msec expired remove bt flag\n", \
+                               if (g_bt->dhcp_done) {
+                                       WL_TRACE_COEX(("%s DHCP Done before T2 expiration\n", \
+                                               __FUNCTION__));
+                               } else {
+                                       WL_TRACE_COEX(("%s DHCP wait interval T2:%d msec expired\n",
                                                __FUNCTION__, BT_DHCP_FLAG_FORCE_TIME));
-                               
+                               }
+
                                if (g_bt->dev)  wl_iw_bt_flag_set(g_bt->dev, FALSE);
                                g_bt->bt_state = BT_DHCP_IDLE;
                                g_bt->timer_on = 0;
                                break;
+
                        default:
                                WL_ERROR(("%s error g_status=%d !!!\n", __FUNCTION__, \
                                          g_bt->bt_state));
@@ -7409,13 +8203,16 @@ _bt_dhcp_sysioc_thread(void *data)
                                g_bt->bt_state = BT_DHCP_IDLE;
                                g_bt->timer_on = 0;
                                break;
-                }
+               }
+
+               net_os_wake_unlock(g_bt->dev);
        }
 
        if (g_bt->timer_on) {
-               del_timer(&g_bt->timer);
                g_bt->timer_on = 0;
+               del_timer_sync(&g_bt->timer);
        }
+
        complete_and_exit(&g_bt->bt_exited, 0);
 }
 
@@ -7468,17 +8265,22 @@ wl_iw_bt_init(struct net_device *dev)
        return 0;
 }
 
-int wl_iw_attach(struct net_device *dev, void * dhdp)
+int wl_iw_attach(struct net_device *dev, void *dhdp)
 {
        int params_size;
        wl_iw_t *iw;
 #if defined(WL_IW_USE_ISCAN)
        iscan_info_t *iscan = NULL;
+#endif
+
+       mutex_init(&wl_cache_lock);
 
+#if defined(WL_IW_USE_ISCAN)
        if (!dev)
                return 0;
 
-       
+       memset(&g_wl_iw_params, 0, sizeof(wl_iw_extra_params_t));
+
 #ifdef CSCAN
        params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params)) +
            (WL_NUMCHANNELS * sizeof(uint16)) + WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
@@ -7486,11 +8288,9 @@ int wl_iw_attach(struct net_device *dev, void * dhdp)
        params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params));
 #endif 
        iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL);
-
        if (!iscan)
                return -ENOMEM;
        memset(iscan, 0, sizeof(iscan_info_t));
-
        
        iscan->iscan_ex_params_p = (wl_iscan_params_t*)kmalloc(params_size, GFP_KERNEL);
        if (!iscan->iscan_ex_params_p)
@@ -7501,12 +8301,13 @@ int wl_iw_attach(struct net_device *dev, void * dhdp)
        g_iscan = iscan;
        iscan->dev = dev;
        iscan->iscan_state = ISCAN_STATE_IDLE;
-
+#if defined(CONFIG_FIRST_SCAN)
        g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
+       g_first_counter_scans = 0;
        g_iscan->scan_flag = 0;
+#endif
 
-       
-       iscan->timer_ms    = 3000;
+       iscan->timer_ms    = 8000;
        init_timer(&iscan->timer);
        iscan->timer.data = (ulong)iscan;
        iscan->timer.function = wl_iw_timerfunc;
@@ -7516,19 +8317,15 @@ int wl_iw_attach(struct net_device *dev, void * dhdp)
        iscan->sysioc_pid = kernel_thread(_iscan_sysioc_thread, iscan, 0);
        if (iscan->sysioc_pid < 0)
                return -ENOMEM;
-#endif 
+#endif
 
        iw = *(wl_iw_t **)netdev_priv(dev);
        iw->pub = (dhd_pub_t *)dhdp;
-       MUTEX_LOCK_INIT(iw->pub);
-       MUTEX_LOCK_WL_SCAN_SET_INIT();
 #ifdef SOFTAP
        priv_dev = dev;
-       MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub);
 #endif 
        g_scan = NULL;
 
-       
        g_scan = (void *)kmalloc(G_SCAN_RESULTS, GFP_KERNEL);
        if (!g_scan)
                return -ENOMEM;
@@ -7537,12 +8334,10 @@ int wl_iw_attach(struct net_device *dev, void * dhdp)
        g_scan_specified_ssid = 0;
 
 #if !defined(CSCAN)
-       
        wl_iw_init_ss_cache_ctrl();
-#endif 
-       
-       wl_iw_bt_init(dev);
+#endif
 
+       wl_iw_bt_init(dev);
 
        return 0;
 }
@@ -7559,17 +8354,17 @@ void wl_iw_detach(void)
                KILL_PROC(iscan->sysioc_pid, SIGTERM);
                wait_for_completion(&iscan->sysioc_exited);
        }
-       MUTEX_LOCK_WL_SCAN_SET();
+       mutex_lock(&wl_cache_lock);
        while (iscan->list_hdr) {
                buf = iscan->list_hdr->next;
                kfree(iscan->list_hdr);
                iscan->list_hdr = buf;
        }
-       MUTEX_UNLOCK_WL_SCAN_SET();
        kfree(iscan->iscan_ex_params_p);
        kfree(iscan);
        g_iscan = NULL;
-#endif 
+       mutex_unlock(&wl_cache_lock);
+#endif
 
        if (g_scan)
                kfree(g_scan);
@@ -7577,15 +8372,12 @@ void wl_iw_detach(void)
        g_scan = NULL;
 #if !defined(CSCAN)
        wl_iw_release_ss_cache_ctrl();
-#endif 
+#endif
        wl_iw_bt_release();
-
 #ifdef SOFTAP
        if (ap_cfg_running) {
                WL_TRACE(("\n%s AP is going down\n", __FUNCTION__));
-               
                wl_iw_send_priv_event(priv_dev, "AP_DOWN");
        }
 #endif
-
 }
index 12c7c19d5d7836a654ab87e08f5527fbe95a5443..928291fe589a58e801ce7e66e9653e68bf4d925c 100644 (file)
@@ -21,7 +21,7 @@
  * software in any way with any other Broadcom software provided under a license
  * other than the GPL, without Broadcom's express prior written consent.
  *
- * $Id: wl_iw.h,v 1.5.34.1.6.24 2010/07/27 20:46:02 Exp $
+ * $Id: wl_iw.h,v 1.5.34.1.6.36.4.15 2010/11/17 03:13:51 Exp $
  */
 
 
 #define GET_HOME_DWELL                 "HOME="
 #define GET_SCAN_TYPE                  "TYPE="
 
-#define BAND_GET_CMD                           "BANDGET"
-#define BAND_SET_CMD                           "BANDSET"
-
-
-#define        WL_IW_RSSI_MINVAL               -200    
-#define        WL_IW_RSSI_NO_SIGNAL    -91     
-#define        WL_IW_RSSI_VERY_LOW     -80     
-#define        WL_IW_RSSI_LOW          -70     
-#define        WL_IW_RSSI_GOOD         -68     
-#define        WL_IW_RSSI_VERY_GOOD    -58     
-#define        WL_IW_RSSI_EXCELLENT    -57     
-#define        WL_IW_RSSI_INVALID       0      
-#define MAX_WX_STRING 80
-#define isprint(c) bcm_isprint(c)
+#define BAND_GET_CMD                           "GETBAND"
+#define BAND_SET_CMD                           "SETBAND"
+#define DTIM_SKIP_GET_CMD                      "DTIMSKIPGET"
+#define DTIM_SKIP_SET_CMD                      "DTIMSKIPSET"
+#define SETSUSPEND_CMD                         "SETSUSPENDOPT"
+#define PNOSSIDCLR_SET_CMD                     "PNOSSIDCLR"
+#define PNOSETUP_SET_CMD                       "PNOSETUP "
+#define PNOENABLE_SET_CMD                      "PNOFORCE"
+#define PNODEBUG_SET_CMD                       "PNODEBUG"
+#define SETDFSCHANNELS_CMD                     "SETDFSCHANNELS"
+
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+
+
+typedef struct wl_iw_extra_params {
+       int     target_channel;
+} wl_iw_extra_params_t;
+
+#define        WL_IW_RSSI_MINVAL       -200
+#define        WL_IW_RSSI_NO_SIGNAL    -91
+#define        WL_IW_RSSI_VERY_LOW     -80
+#define        WL_IW_RSSI_LOW          -70
+#define        WL_IW_RSSI_GOOD         -68
+#define        WL_IW_RSSI_VERY_GOOD    -58
+#define        WL_IW_RSSI_EXCELLENT    -57
+#define        WL_IW_RSSI_INVALID       0
+#define MAX_WX_STRING          80
+#define isprint(c)             bcm_isprint(c)
 #define WL_IW_SET_ACTIVE_SCAN  (SIOCIWFIRSTPRIV+1)
-#define WL_IW_GET_RSSI                 (SIOCIWFIRSTPRIV+3)
+#define WL_IW_GET_RSSI         (SIOCIWFIRSTPRIV+3)
 #define WL_IW_SET_PASSIVE_SCAN (SIOCIWFIRSTPRIV+5)
 #define WL_IW_GET_LINK_SPEED   (SIOCIWFIRSTPRIV+7)
 #define WL_IW_GET_CURR_MACADDR (SIOCIWFIRSTPRIV+9)
-#define WL_IW_SET_STOP                         (SIOCIWFIRSTPRIV+11)
-#define WL_IW_SET_START                        (SIOCIWFIRSTPRIV+13)
+#define WL_IW_SET_STOP         (SIOCIWFIRSTPRIV+11)
+#define WL_IW_SET_START                (SIOCIWFIRSTPRIV+13)
 
 
 #define WL_SET_AP_CFG           (SIOCIWFIRSTPRIV+15)
 #define AP_LPB_CMD              (SIOCIWFIRSTPRIV+23)
 #define WL_AP_STOP              (SIOCIWFIRSTPRIV+25)
 #define WL_FW_RELOAD            (SIOCIWFIRSTPRIV+27)
-#define WL_COMBO_SCAN            (SIOCIWFIRSTPRIV+29)
-#define WL_AP_SPARE3            (SIOCIWFIRSTPRIV+31)
-#define                G_SCAN_RESULTS 8*1024
-#define                WE_ADD_EVENT_FIX        0x80
-#define          G_WLAN_SET_ON 0
-#define          G_WLAN_SET_OFF        1
+#define WL_AP_STA_DISASSOC             (SIOCIWFIRSTPRIV+29)
+#define WL_COMBO_SCAN           (SIOCIWFIRSTPRIV+31)
+
+#define G_SCAN_RESULTS         (8*1024)
+#define WE_ADD_EVENT_FIX       0x80
+#define G_WLAN_SET_ON          0
+#define G_WLAN_SET_OFF         1
 
 #define CHECK_EXTRA_FOR_NULL(extra) \
 if (!extra) { \
@@ -92,9 +108,9 @@ typedef struct wl_iw {
        struct iw_statistics wstats;
 
        int spy_num;
-       uint32 pwsec;                   
-       uint32 gwsec;                   
-       bool privacy_invoked;           
+       uint32 pwsec;
+       uint32 gwsec;
+       bool privacy_invoked;
 
        struct ether_addr spy_addr[IW_MAX_SPY];
        struct iw_quality spy_qual[IW_MAX_SPY];
@@ -102,18 +118,17 @@ typedef struct wl_iw {
        dhd_pub_t * pub;
 } wl_iw_t;
 
-int     wl_control_wl_start(struct net_device *dev);
-#define WLC_IW_SS_CACHE_MAXLEN                         512
+#define WLC_IW_SS_CACHE_MAXLEN                         2048
 #define WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN      32
 #define WLC_IW_BSS_INFO_MAXLEN                                 \
        (WLC_IW_SS_CACHE_MAXLEN - WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN)
 
 typedef struct wl_iw_ss_cache {
        struct wl_iw_ss_cache *next;
+       int dirty;
        uint32 buflen;
        uint32 version;
        uint32 count;
-       int dirty;
        wl_bss_info_t bss_info[1];
 } wl_iw_ss_cache_t;
 
@@ -126,6 +141,7 @@ typedef struct wl_iw_ss_cache_ctrl {
        uint m_cons_br_scan_cnt;        
        struct timer_list *m_timer;     
 } wl_iw_ss_cache_ctrl_t;
+
 typedef enum broadcast_first_scan {
        BROADCAST_SCAN_FIRST_IDLE = 0,
        BROADCAST_SCAN_FIRST_STARTED,
@@ -141,36 +157,51 @@ struct ap_profile {
        uint8   ssid[SSID_LEN];
        uint8   sec[SEC_LEN];
        uint8   key[KEY_LEN];
-       uint32  channel; 
+       uint32  channel;
        uint32  preamble;
-       uint32  max_scb;        
+       uint32  max_scb;
+       uint32  closednet;
+       char country_code[WLC_CNTRY_BUF_SZ];
 };
 
 
 #define MACLIST_MODE_DISABLED  0
-#define MACLIST_MODE_ENABLED   1
+#define MACLIST_MODE_DENY              1
 #define MACLIST_MODE_ALLOW             2
 struct mflist {
        uint count;
        struct ether_addr ea[16];
 };
+
 struct mac_list_set {
        uint32  mode;
-       struct mflist white_list;
-       struct mflist black_list;
+       struct mflist mac_list;
 };
-#endif   
+#endif
 
 #if WIRELESS_EXT > 12
 #include <net/iw_handler.h>
 extern const struct iw_handler_def wl_iw_handler_def;
-#endif 
+#endif
 
 extern int wl_iw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
 extern void wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data);
 extern int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats);
 int wl_iw_attach(struct net_device *dev, void * dhdp);
 void wl_iw_detach(void);
+int wl_control_wl_start(struct net_device *dev);
+
+extern int net_os_wake_lock(struct net_device *dev);
+extern int net_os_wake_unlock(struct net_device *dev);
+extern int net_os_wake_lock_timeout(struct net_device *dev);
+extern int net_os_wake_lock_timeout_enable(struct net_device *dev);
+extern int net_os_set_suspend_disable(struct net_device *dev, int val);
+extern int net_os_set_suspend(struct net_device *dev, int val);
+extern int net_os_set_dtim_skip(struct net_device *dev, int val);
+extern int net_os_set_packet_filter(struct net_device *dev, int val);
+extern void dhd_bus_country_set(struct net_device *dev, char *country_code);
+extern char *dhd_bus_country_get(struct net_device *dev);
+extern int dhd_get_dtim_skip(dhd_pub_t *dhd);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
 #define IWE_STREAM_ADD_EVENT(info, stream, ends, iwe, extra) \
@@ -188,6 +219,32 @@ void wl_iw_detach(void);
        iwe_stream_add_point(stream, ends, iwe, extra)
 #endif
 
+extern int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled);
+extern int dhd_pno_clean(dhd_pub_t *dhd);
+extern int dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid, ushort  scan_fr);
+extern int dhd_pno_get_status(dhd_pub_t *dhd);
+extern int dhd_dev_pno_reset(struct net_device *dev);
+extern int dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local, \
+                                int nssid, ushort  scan_fr);
+extern int dhd_dev_pno_enable(struct net_device *dev,  int pfn_enabled);
+extern int dhd_dev_get_pno_status(struct net_device *dev);
+
+#define PNO_TLV_PREFIX                 'S'
+#define PNO_TLV_VERSION                        '1'
+#define PNO_TLV_SUBVERSION             '2'
+#define PNO_TLV_RESERVED               '0'
+#define PNO_TLV_TYPE_SSID_IE           'S'
+#define PNO_TLV_TYPE_TIME              'T'
+#define  PNO_EVENT_UP                  "PNO_EVENT"
+#define PNO_SCAN_MAX_FW                        508
+
+typedef struct cmd_tlv {
+       char prefix;
+       char version;
+       char subver;
+       char reserved;
+} cmd_tlv_t;
+
 #if defined(CSCAN)
 
 typedef struct cscan_tlv {
@@ -201,13 +258,13 @@ typedef struct cscan_tlv {
 #define CSCAN_TLV_PREFIX                       'S'
 #define CSCAN_TLV_VERSION                      1
 #define CSCAN_TLV_SUBVERSION                   0
-#define CSCAN_TLV_TYPE_SSID_IE          'S'
-#define CSCAN_TLV_TYPE_CHANNEL_IE   'C'
-#define CSCAN_TLV_TYPE_NPROBE_IE     'N'
-#define CSCAN_TLV_TYPE_ACTIVE_IE      'A'
-#define CSCAN_TLV_TYPE_PASSIVE_IE    'P'
-#define CSCAN_TLV_TYPE_HOME_IE         'H'
-#define CSCAN_TLV_TYPE_STYPE_IE        'T'
+#define CSCAN_TLV_TYPE_SSID_IE                 'S'
+#define CSCAN_TLV_TYPE_CHANNEL_IE              'C'
+#define CSCAN_TLV_TYPE_NPROBE_IE               'N'
+#define CSCAN_TLV_TYPE_ACTIVE_IE               'A'
+#define CSCAN_TLV_TYPE_PASSIVE_IE              'P'
+#define CSCAN_TLV_TYPE_HOME_IE                 'H'
+#define CSCAN_TLV_TYPE_STYPE_IE                        'T'
 
 extern int wl_iw_parse_channel_list_tlv(char** list_str, uint16* channel_list, \
                                        int channel_num, int *bytes_left);
diff --git a/drivers/net/wireless/bcm4319/wl_iw_dbg.c b/drivers/net/wireless/bcm4319/wl_iw_dbg.c
deleted file mode 100644 (file)
index 2bc03de..0000000
+++ /dev/null
@@ -1,7895 +0,0 @@
-/*
- * Linux Wireless Extensions support
- *
- * Copyright (C) 1999-2010, Broadcom Corporation
- * 
- *      Unless you and Broadcom execute a separate written software license
- * agreement governing use of this software, this software is licensed to you
- * under the terms of the GNU General Public License version 2 (the "GPL"),
- * available at http://www.broadcom.com/licenses/GPLv2.php, with the
- * following added to such license:
- * 
- *      As a special exception, the copyright holders of this software give you
- * permission to link this software with independent modules, and to copy and
- * distribute the resulting executable under terms of your choice, provided that
- * you also meet, for each linked independent module, the terms and conditions of
- * the license of that module.  An independent module is a module which is not
- * derived from this software.  The special exception does not apply to any
- * modifications of the software.
- * 
- *      Notwithstanding the above, under no circumstances may you combine this
- * software in any way with any other Broadcom software provided under a license
- * other than the GPL, without Broadcom's express prior written consent.
- *
- * $Id: wl_iw.c,v 1.51.4.9.2.6.4.124 2010/07/27 20:46:02 Exp $
- */
-
-#include <wlioctl.h>
-
-#include <typedefs.h>
-#include <linuxver.h>
-#include <osl.h>
-
-#include <bcmutils.h>
-#include <bcmendian.h>
-#include <proto/ethernet.h>
-
-#include <linux/if_arp.h>
-#include <asm/uaccess.h>
-
-#include <dngl_stats.h>
-#include <dhd.h>
-#include <dhdioctl.h>
-
-typedef void wlc_info_t;
-typedef void wl_info_t;
-typedef const struct si_pub  si_t;
-#include <wlioctl.h>
-
-#include <proto/ethernet.h>
-#include <dngl_stats.h>
-#include <dhd.h>
-#include <dhd_dbg.h>
-#define WL_ERROR(x)  DHD_ERROR(x)
-#define WL_TRACE(x)  DHD_TRACE(x)
-#define WL_ASSOC(x)  DHD_TRACE(x)
-#define WL_INFORM(x) DHD_TRACE(x)
-#define WL_WSEC(x)   DHD_TRACE(x)
-#define WL_SCAN(x)   DHD_TRACE(x)
-
-#include <wl_iw.h>
-
-#ifndef IW_ENCODE_ALG_SM4
-#define IW_ENCODE_ALG_SM4 0x20
-#endif
-
-#ifndef IW_AUTH_WAPI_ENABLED
-#define IW_AUTH_WAPI_ENABLED 0x20
-#endif
-
-#ifndef IW_AUTH_WAPI_VERSION_1
-#define IW_AUTH_WAPI_VERSION_1 0x00000008
-#endif
-
-#ifndef IW_AUTH_CIPHER_SMS4
-#define IW_AUTH_CIPHER_SMS4    0x00000020
-#endif
-
-#ifndef IW_AUTH_KEY_MGMT_WAPI_PSK
-#define IW_AUTH_KEY_MGMT_WAPI_PSK 4
-#endif
-
-#ifndef IW_AUTH_KEY_MGMT_WAPI_CERT
-#define IW_AUTH_KEY_MGMT_WAPI_CERT 8
-#endif
-
-
-#define IW_WSEC_ENABLED(wsec)  ((wsec) & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED | SMS4_ENABLED))
-
-#include <linux/rtnetlink.h>
-
-#define WL_IW_USE_ISCAN  1
-#define ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS  1
-
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
-       struct mutex  g_wl_ss_scan_lock; 
-#endif 
-
-#if defined(SOFTAP)
-#define WL_SOFTAP(x) DHD_TRACE(x)
-static struct net_device *priv_dev;
-static bool    ap_cfg_running = FALSE;
-static bool    ap_fw_loaded = FALSE;
-struct net_device *ap_net_dev = NULL;
-struct semaphore  ap_eth_sema;
-static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap);
-static int wl_iw_softap_deassoc_stations(struct net_device *dev);
-#endif 
-
-#define WL_IW_IOCTL_CALL(func_call) \
-       do {                            \
-               func_call;              \
-       } while (0)
-
-static int             g_onoff = G_WLAN_SET_ON;
-
-extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
-       uint32 reason, char* stringBuf, uint buflen);
-#include <bcmsdbus.h>
-extern void dhd_customer_gpio_wlan_ctrl(int onoff);
-extern uint dhd_dev_reset(struct net_device *dev, uint8 flag);
-extern void dhd_dev_init_ioctl(struct net_device *dev);
-int dev_iw_write_cfg1_bss_var(struct net_device *dev, int val);
-
-uint wl_msg_level = WL_ERROR_VAL;
-
-#define MAX_WLIW_IOCTL_LEN 1024
-
-#if defined(IL_BIGENDIAN)
-#include <bcmendian.h>
-#define htod32(i) (bcmswap32(i))
-#define htod16(i) (bcmswap16(i))
-#define dtoh32(i) (bcmswap32(i))
-#define dtoh16(i) (bcmswap16(i))
-#define htodchanspec(i) htod16(i)
-#define dtohchanspec(i) dtoh16(i)
-#else
-#define htod32(i) i
-#define htod16(i) i
-#define dtoh32(i) i
-#define dtoh16(i) i
-#define htodchanspec(i) i
-#define dtohchanspec(i) i
-#endif
-
-#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 
-
-#if WIRELESS_EXT < 19
-#define IW_IOCTL_IDX(cmd)      ((cmd) - SIOCIWFIRST)
-#define IW_EVENT_IDX(cmd)      ((cmd) - IWEVFIRST)
-#endif 
-
-static void *g_scan = NULL;
-static volatile uint g_scan_specified_ssid;    
-static wlc_ssid_t g_specific_ssid;             
-
-static wlc_ssid_t g_ssid;
-
-static wl_iw_ss_cache_ctrl_t g_ss_cache_ctrl;  
-static volatile uint g_first_broadcast_scan;   
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
-#define DAEMONIZE(a) daemonize(a); \
-       allow_signal(SIGKILL); \
-       allow_signal(SIGTERM);
-#else 
-#define RAISE_RX_SOFTIRQ() \
-       cpu_raise_softirq(smp_processor_id(), NET_RX_SOFTIRQ)
-#define DAEMONIZE(a) daemonize(); \
-       do { if (a) \
-               strncpy(current->comm, a, MIN(sizeof(current->comm), (strlen(a) + 1))); \
-       } while (0);
-#endif 
-
-#if defined(WL_IW_USE_ISCAN)
-#if  !defined(CSCAN)
-static void wl_iw_free_ss_cache(void);
-static int   wl_iw_run_ss_cache_timer(int kick_off);
-#endif 
-int  wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
-static int dev_wlc_bufvar_set(struct net_device *dev, char *name, char *buf, int len);
-#define ISCAN_STATE_IDLE   0
-#define ISCAN_STATE_SCANING 1
-
-#define WLC_IW_ISCAN_MAXLEN   2048
-typedef struct iscan_buf {
-       struct iscan_buf * next;
-       char   iscan_buf[WLC_IW_ISCAN_MAXLEN];
-} iscan_buf_t;
-
-typedef struct iscan_info {
-       struct net_device *dev;
-       struct timer_list timer;
-       uint32 timer_ms;
-       uint32 timer_on;
-       int    iscan_state;
-       iscan_buf_t * list_hdr;
-       iscan_buf_t * list_cur;
-       
-       long sysioc_pid;
-       struct semaphore sysioc_sem;
-       struct completion sysioc_exited;
-
-       uint32 scan_flag;       
-#if defined CSCAN
-       char ioctlbuf[WLC_IOCTL_MEDLEN];
-#else
-       char ioctlbuf[WLC_IOCTL_SMLEN];
-#endif 
-       
-       wl_iscan_params_t *iscan_ex_params_p;
-       int iscan_ex_param_size;
-} iscan_info_t;
-#define  COEX_DHCP 1 
-static void wl_iw_bt_flag_set(struct net_device *dev, bool set);
-static void wl_iw_bt_release(void);
-
-typedef enum bt_coex_status {
-       BT_DHCP_IDLE = 0,
-       BT_DHCP_START,
-       BT_DHCP_OPPORTUNITY_WINDOW,
-       BT_DHCP_FLAG_FORCE_TIMEOUT
-} coex_status_t;
-#define BT_DHCP_OPPORTUNITY_WINDOW_TIEM        2500    
-#define BT_DHCP_FLAG_FORCE_TIME                                5500    
-
-typedef struct bt_info {
-       struct net_device *dev;
-       struct timer_list timer;
-       uint32 timer_ms;
-       uint32 timer_on;
-       int     bt_state;
-
-       
-       long bt_pid;
-       struct semaphore bt_sem;
-       struct completion bt_exited;
-} bt_info_t;
-
-bt_info_t *g_bt = NULL;
-static void wl_iw_bt_timerfunc(ulong data);
-iscan_info_t *g_iscan = NULL;
-static void wl_iw_timerfunc(ulong 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, uint16 action);
-#endif 
-static int
-wl_iw_set_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-);
-static int
-wl_iw_get_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-);
-
-static uint
-wl_iw_get_scan_prep(
-       wl_scan_results_t *list,
-       struct iw_request_info *info,
-       char *extra,
-       short max_size
-);
-
-
-static void swap_key_from_BE(
-               wl_wsec_key_t *key
-)
-{
-       key->index = htod32(key->index);
-       key->len = htod32(key->len);
-       key->algo = htod32(key->algo);
-       key->flags = htod32(key->flags);
-       key->rxiv.hi = htod32(key->rxiv.hi);
-       key->rxiv.lo = htod16(key->rxiv.lo);
-       key->iv_initialized = htod32(key->iv_initialized);
-}
-
-static void swap_key_to_BE(
-               wl_wsec_key_t *key
-)
-{
-       key->index = dtoh32(key->index);
-       key->len = dtoh32(key->len);
-       key->algo = dtoh32(key->algo);
-       key->flags = dtoh32(key->flags);
-       key->rxiv.hi = dtoh32(key->rxiv.hi);
-       key->rxiv.lo = dtoh16(key->rxiv.lo);
-       key->iv_initialized = dtoh32(key->iv_initialized);
-}
-
-
-static const char* cmd2nam(int cmd)
-{
-       const char *n="";
-#if defined(DHD_DEBUG)
-       int i=0;
-       struct _WLCNVStruct {
-               const char *n;
-               int v;
-       } wlcnv[] = {
-               {"WLC_GET_MAGIC", 0},
-               {"WLC_GET_VERSION", 1},
-               {"WLC_UP", 2},
-               {"WLC_DOWN", 3},
-               {"WLC_GET_LOOP", 4},
-               {"WLC_SET_LOOP", 5},
-               {"WLC_DUMP", 6},
-               {"WLC_GET_MSGLEVEL", 7},
-               {"WLC_SET_MSGLEVEL", 8},
-               {"WLC_GET_PROMISC", 9},
-               {"WLC_SET_PROMISC", 10},
-               {"WLC_GET_RATE", 12},
-               {"WLC_GET_INSTANCE", 14},
-               {"WLC_GET_INFRA", 19},
-               {"WLC_SET_INFRA", 20},
-               {"WLC_GET_AUTH", 21},
-               {"WLC_SET_AUTH", 22},
-               {"WLC_GET_BSSID", 23},
-               {"WLC_SET_BSSID", 24},
-               {"WLC_GET_SSID", 25},
-               {"WLC_SET_SSID", 26},
-               {"WLC_RESTART", 27},
-               {"WLC_GET_CHANNEL", 29},
-               {"WLC_SET_CHANNEL", 30},
-               {"WLC_GET_SRL", 31},
-               {"WLC_SET_SRL", 32},
-               {"WLC_GET_LRL", 33},
-               {"WLC_SET_LRL", 34},
-               {"WLC_GET_PLCPHDR", 35},
-               {"WLC_SET_PLCPHDR", 36},
-               {"WLC_GET_RADIO", 37},
-               {"WLC_SET_RADIO", 38},
-               {"WLC_GET_PHYTYPE", 39},
-               {"WLC_DUMP_RATE", 40},
-               {"WLC_SET_RATE_PARAMS", 41},
-               {"WLC_GET_KEY", 44},
-               {"WLC_SET_KEY", 45},
-               {"WLC_GET_REGULATORY", 46},
-               {"WLC_SET_REGULATORY", 47},
-               {"WLC_GET_PASSIVE_SCAN", 48},
-               {"WLC_SET_PASSIVE_SCAN", 49},
-               {"WLC_SCAN", 50},
-               {"WLC_SCAN_RESULTS", 51},
-               {"WLC_DISASSOC", 52},
-               {"WLC_REASSOC", 53},
-               {"WLC_GET_ROAM_TRIGGER", 54},
-               {"WLC_SET_ROAM_TRIGGER", 55},
-               {"WLC_GET_ROAM_DELTA", 56},
-               {"WLC_SET_ROAM_DELTA", 57},
-               {"WLC_GET_ROAM_SCAN_PERIOD", 58},
-               {"WLC_SET_ROAM_SCAN_PERIOD", 59},
-               {"WLC_EVM", 60},
-               {"WLC_GET_TXANT", 61},
-               {"WLC_SET_TXANT", 62},
-               {"WLC_GET_ANTDIV", 63},
-               {"WLC_SET_ANTDIV", 64},
-               {"WLC_GET_CLOSED", 67},
-               {"WLC_SET_CLOSED", 68},
-               {"WLC_GET_MACLIST", 69},
-               {"WLC_SET_MACLIST", 70},
-               {"WLC_GET_RATESET", 71},
-               {"WLC_SET_RATESET", 72},
-               {"WLC_LONGTRAIN", 74},
-               {"WLC_GET_BCNPRD", 75},
-               {"WLC_SET_BCNPRD", 76},
-               {"WLC_GET_DTIMPRD", 77},
-               {"WLC_SET_DTIMPRD", 78},
-               {"WLC_GET_SROM", 79},
-               {"WLC_SET_SROM", 80},
-               {"WLC_GET_WEP_RESTRICT", 81},
-               {"WLC_SET_WEP_RESTRICT", 82},
-               {"WLC_GET_COUNTRY", 83},
-               {"WLC_SET_COUNTRY", 84},
-               {"WLC_GET_PM", 85},
-               {"WLC_SET_PM", 86},
-               {"WLC_GET_WAKE", 87},
-               {"WLC_SET_WAKE", 88},
-               {"WLC_GET_FORCELINK", 90},
-               {"WLC_SET_FORCELINK", 91},
-               {"WLC_FREQ_ACCURACY", 92},
-               {"WLC_CARRIER_SUPPRESS", 93},
-               {"WLC_GET_PHYREG", 94},
-               {"WLC_SET_PHYREG", 95},
-               {"WLC_GET_RADIOREG", 96},
-               {"WLC_SET_RADIOREG", 97},
-               {"WLC_GET_REVINFO", 98},
-               {"WLC_GET_UCANTDIV", 99},
-               {"WLC_SET_UCANTDIV", 100},
-               {"WLC_R_REG", 101},
-               {"WLC_W_REG", 102},
-               {"WLC_GET_MACMODE", 105},
-               {"WLC_SET_MACMODE", 106},
-               {"WLC_GET_MONITOR", 107},
-               {"WLC_SET_MONITOR", 108},
-               {"WLC_GET_GMODE", 109},
-               {"WLC_SET_GMODE", 110},
-               {"WLC_GET_LEGACY_ERP", 111},
-               {"WLC_SET_LEGACY_ERP", 112},
-               {"WLC_GET_RX_ANT", 113},
-               {"WLC_GET_CURR_RATESET", 114},
-               {"WLC_GET_SCANSUPPRESS", 115},
-               {"WLC_SET_SCANSUPPRESS", 116},
-               {"WLC_GET_AP", 117},
-               {"WLC_SET_AP", 118},
-               {"WLC_GET_EAP_RESTRICT", 119},
-               {"WLC_SET_EAP_RESTRICT", 120},
-               {"WLC_SCB_AUTHORIZE", 121},
-               {"WLC_SCB_DEAUTHORIZE", 122},
-               {"WLC_GET_WDSLIST", 123},
-               {"WLC_SET_WDSLIST", 124},
-               {"WLC_GET_ATIM", 125},
-               {"WLC_SET_ATIM", 126},
-               {"WLC_GET_RSSI", 127},
-               {"WLC_GET_PHYANTDIV", 128},
-               {"WLC_SET_PHYANTDIV", 129},
-               {"WLC_AP_RX_ONLY", 130},
-               {"WLC_GET_TX_PATH_PWR", 131},
-               {"WLC_SET_TX_PATH_PWR", 132},
-               {"WLC_GET_WSEC", 133},
-               {"WLC_SET_WSEC", 134},
-               {"WLC_GET_PHY_NOISE", 135},
-               {"WLC_GET_BSS_INFO", 136},
-               {"WLC_GET_PKTCNTS", 137},
-               {"WLC_GET_LAZYWDS", 138},
-               {"WLC_SET_LAZYWDS", 139},
-               {"WLC_GET_BANDLIST", 140},
-               {"WLC_GET_BAND", 141},
-               {"WLC_SET_BAND", 142},
-               {"WLC_SCB_DEAUTHENTICATE", 143},
-               {"WLC_GET_SHORTSLOT", 144},
-               {"WLC_GET_SHORTSLOT_OVERRIDE", 145},
-               {"WLC_SET_SHORTSLOT_OVERRIDE", 146},
-               {"WLC_GET_SHORTSLOT_RESTRICT", 147},
-               {"WLC_SET_SHORTSLOT_RESTRICT", 148},
-               {"WLC_GET_GMODE_PROTECTION", 149},
-               {"WLC_GET_GMODE_PROTECTION_OVERRIDE", 150},
-               {"WLC_SET_GMODE_PROTECTION_OVERRIDE", 151},
-               {"WLC_UPGRADE", 152},
-               {"WLC_GET_IGNORE_BCNS", 155},
-               {"WLC_SET_IGNORE_BCNS", 156},
-               {"WLC_GET_SCB_TIMEOUT", 157},
-               {"WLC_SET_SCB_TIMEOUT", 158},
-               {"WLC_GET_ASSOCLIST", 159},
-               {"WLC_GET_CLK", 160},
-               {"WLC_SET_CLK", 161},
-               {"WLC_GET_UP", 162},
-               {"WLC_OUT", 163},
-               {"WLC_GET_WPA_AUTH", 164},
-               {"WLC_SET_WPA_AUTH", 165},
-               {"WLC_GET_UCFLAGS", 166},
-               {"WLC_SET_UCFLAGS", 167},
-               {"WLC_GET_PWRIDX", 168},
-               {"WLC_SET_PWRIDX", 169},
-               {"WLC_GET_TSSI", 170},
-               {"WLC_GET_SUP_RATESET_OVERRIDE", 171},
-               {"WLC_SET_SUP_RATESET_OVERRIDE", 172},
-               {"WLC_GET_PROTECTION_CONTROL", 178},
-               {"WLC_SET_PROTECTION_CONTROL", 179},
-               {"WLC_GET_PHYLIST", 180},
-               {"WLC_ENCRYPT_STRENGTH", 181},
-               {"WLC_DECRYPT_STATUS", 182},
-               {"WLC_GET_KEY_SEQ", 183},
-               {"WLC_GET_SCAN_CHANNEL_TIME", 184},
-               {"WLC_SET_SCAN_CHANNEL_TIME", 185},
-               {"WLC_GET_SCAN_UNASSOC_TIME", 186},
-               {"WLC_SET_SCAN_UNASSOC_TIME", 187},
-               {"WLC_GET_SCAN_HOME_TIME", 188},
-               {"WLC_SET_SCAN_HOME_TIME", 189},
-               {"WLC_GET_SCAN_NPROBES", 190},
-               {"WLC_SET_SCAN_NPROBES", 191},
-               {"WLC_GET_PRB_RESP_TIMEOUT", 192},
-               {"WLC_SET_PRB_RESP_TIMEOUT", 193},
-               {"WLC_GET_ATTEN", 194},
-               {"WLC_SET_ATTEN", 195},
-               {"WLC_GET_SHMEM", 196},
-               {"WLC_SET_SHMEM", 197},
-               {"WLC_SET_WSEC_TEST", 200},
-               {"WLC_SCB_DEAUTHENTICATE_FOR_REASON", 201},
-               {"WLC_TKIP_COUNTERMEASURES", 202},
-               {"WLC_GET_PIOMODE", 203},
-               {"WLC_SET_PIOMODE", 204},
-               {"WLC_SET_ASSOC_PREFER", 205},
-               {"WLC_GET_ASSOC_PREFER", 206},
-               {"WLC_SET_ROAM_PREFER", 207},
-               {"WLC_GET_ROAM_PREFER", 208},
-               {"WLC_SET_LED", 209},
-               {"WLC_GET_LED", 210},
-               {"WLC_GET_INTERFERENCE_MODE", 211},
-               {"WLC_SET_INTERFERENCE_MODE", 212},
-               {"WLC_GET_CHANNEL_QA", 213},
-               {"WLC_START_CHANNEL_QA", 214},
-               {"WLC_GET_CHANNEL_SEL", 215},
-               {"WLC_START_CHANNEL_SEL", 216},
-               {"WLC_GET_VALID_CHANNELS", 217},
-               {"WLC_GET_FAKEFRAG", 218},
-               {"WLC_SET_FAKEFRAG", 219},
-               {"WLC_GET_PWROUT_PERCENTAGE", 220},
-               {"WLC_SET_PWROUT_PERCENTAGE", 221},
-               {"WLC_SET_BAD_FRAME_PREEMPT", 222},
-               {"WLC_GET_BAD_FRAME_PREEMPT", 223},
-               {"WLC_SET_LEAP_LIST", 224},
-               {"WLC_GET_LEAP_LIST", 225},
-               {"WLC_GET_CWMIN", 226},
-               {"WLC_SET_CWMIN", 227},
-               {"WLC_GET_CWMAX", 228},
-               {"WLC_SET_CWMAX", 229},
-               {"WLC_GET_WET", 230},
-               {"WLC_SET_WET", 231},
-               {"WLC_GET_PUB", 232},
-               {"WLC_GET_KEY_PRIMARY", 235},
-               {"WLC_SET_KEY_PRIMARY", 236},
-               {"WLC_GET_ACI_ARGS", 238},
-               {"WLC_SET_ACI_ARGS", 239},
-               {"WLC_UNSET_CALLBACK", 240},
-               {"WLC_SET_CALLBACK", 241},
-               {"WLC_GET_RADAR", 242},
-               {"WLC_SET_RADAR", 243},
-               {"WLC_SET_SPECT_MANAGMENT", 244},
-               {"WLC_GET_SPECT_MANAGMENT", 245},
-               {"WLC_WDS_GET_REMOTE_HWADDR", 246},
-               {"WLC_WDS_GET_WPA_SUP", 247},
-               {"WLC_SET_CS_SCAN_TIMER", 248},
-               {"WLC_GET_CS_SCAN_TIMER", 249},
-               {"WLC_MEASURE_REQUEST", 250},
-               {"WLC_INIT", 251},
-               {"WLC_SEND_QUIET", 252},
-               {"WLC_KEEPALIVE", 253},
-               {"WLC_SEND_PWR_CONSTRAINT", 254},
-               {"WLC_UPGRADE_STATUS", 255},
-               {"WLC_CURRENT_PWR", 256},
-               {"WLC_GET_SCAN_PASSIVE_TIME", 257},
-               {"WLC_SET_SCAN_PASSIVE_TIME", 258},
-               {"WLC_LEGACY_LINK_BEHAVIOR", 259},
-               {"WLC_GET_CHANNELS_IN_COUNTRY", 260},
-               {"WLC_GET_COUNTRY_LIST", 261},
-               {"WLC_GET_VAR", 262},
-               {"WLC_SET_VAR", 263},
-               {"WLC_NVRAM_GET", 264},
-               {"WLC_NVRAM_SET", 265},
-               {"WLC_NVRAM_DUMP", 266},
-               {"WLC_REBOOT", 267},
-               {"WLC_SET_WSEC_PMK", 268},
-               {"WLC_GET_AUTH_MODE", 269},
-               {"WLC_SET_AUTH_MODE", 270},
-               {"WLC_GET_WAKEENTRY", 271},
-               {"WLC_SET_WAKEENTRY", 272},
-               {"WLC_NDCONFIG_ITEM", 273},
-               {"WLC_NVOTPW", 274},
-               {"WLC_OTPW", 275},
-               {"WLC_IOV_BLOCK_GET", 276},
-               {"WLC_IOV_MODULES_GET", 277},
-               {"WLC_SOFT_RESET", 278},
-               {"WLC_GET_ALLOW_MODE", 279},
-               {"WLC_SET_ALLOW_MODE", 280},
-               {"WLC_GET_DESIRED_BSSID", 281},
-               {"WLC_SET_DESIRED_BSSID", 282},
-               {"WLC_DISASSOC_MYAP", 283},
-               {"WLC_GET_NBANDS", 284},
-               {"WLC_GET_BANDSTATES", 285},
-               {"WLC_GET_WLC_BSS_INFO", 286},
-               {"WLC_GET_ASSOC_INFO", 287},
-               {"WLC_GET_OID_PHY", 288},
-               {"WLC_SET_OID_PHY", 289},
-               {"WLC_SET_ASSOC_TIME", 290},
-               {"WLC_GET_DESIRED_SSID", 291},
-               {"WLC_GET_CHANSPEC", 292},
-               {"WLC_GET_ASSOC_STATE", 293},
-               {"WLC_SET_PHY_STATE", 294},
-               {"WLC_GET_SCAN_PENDING", 295},
-               {"WLC_GET_SCANREQ_PENDING", 296},
-               {"WLC_GET_PREV_ROAM_REASON", 297},
-               {"WLC_SET_PREV_ROAM_REASON", 298},
-               {"WLC_GET_BANDSTATES_PI", 299},
-               {"WLC_GET_PHY_STATE", 300},
-               {"WLC_GET_BSS_WPA_RSN", 301},
-               {"WLC_GET_BSS_WPA2_RSN", 302},
-               {"WLC_GET_BSS_BCN_TS", 303},
-               {"WLC_GET_INT_DISASSOC", 304},
-               {"WLC_SET_NUM_PEERS", 305},     
-               {"WLC_GET_NUM_BSS", 306},
-               {"WLC_LAST", 307},
-       };
-
-       while (i < sizeof(wlcnv)/sizeof(wlcnv[0])) {
-               if (wlcnv[i].v == cmd) {
-                       n = wlcnv[i].n;
-                       break;
-               }
-               ++i;
-       }
-#endif /* DHD_DEBUG */
-       return n;
-}
-
-static int dev_wlc_ioctl(      struct net_device *dev,
-       int cmd,
-       void *arg,
-       int len
-)
-{
-       struct ifreq ifr;
-       wl_ioctl_t ioc;
-       mm_segment_t fs;
-       int ret = -EINVAL;
-
-       if (!dev) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return ret;
-       }
-
-       WL_INFORM(("\n%s, PID:%x: send Local IOCTL -> dhd: cmd:%s(%d), buf:%p, len:%d ,\n",
-               __FUNCTION__, current->pid, cmd2nam(cmd), cmd, arg, len));
-
-       if (g_onoff == G_WLAN_SET_ON) 
-       {
-               memset(&ioc, 0, sizeof(ioc));
-               ioc.cmd = cmd;
-               ioc.buf = arg;
-               ioc.len = len;
-
-               strcpy(ifr.ifr_name, dev->name);
-               ifr.ifr_data = (caddr_t) &ioc;
-
-               
-               ret = dev_open(dev);
-               if (ret) {
-                       WL_ERROR(("%s: Error dev_open: %d\n", __func__, ret));
-                       return ret;
-               }
-
-               fs = get_fs();
-               set_fs(get_ds());
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
-               //printk("Calling dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE)\n");
-               ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#else
-               ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#endif 
-               set_fs(fs);
-       }
-       else {
-               WL_TRACE(("%s: call after driver stop : ignored\n", __FUNCTION__));
-       }
-       return ret;
-}
-
-static int
-dev_wlc_intvar_get_reg(
-       struct net_device *dev,
-       char *name,
-       uint  reg,
-       int *retval)
-{
-       union {
-               char buf[WLC_IOCTL_SMLEN];
-               int val;
-       } var;
-       int error;
-
-       uint len;
-       len = bcm_mkiovar(name, (char *)(&reg), sizeof(reg), (char *)(&var), sizeof(var.buf));
-       ASSERT(len);
-       error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len);
-
-       *retval = dtoh32(var.val);
-       return (error);
-}
-
-
-static int
-dev_wlc_intvar_set_reg(
-       struct net_device *dev,
-       char *name,
-       char *addr,
-       char * val)
-{
-       char reg_addr[8];
-
-       memset(reg_addr, 0, sizeof(reg_addr));
-       memcpy((char *)&reg_addr[0], (char *)addr, 4);
-       memcpy((char *)&reg_addr[4], (char *)val, 4);
-
-       return (dev_wlc_bufvar_set(dev, name,  (char *)&reg_addr[0], sizeof(reg_addr)));
-}
-
-
-
-
-static int
-dev_wlc_intvar_set(
-       struct net_device *dev,
-       char *name,
-       int val)
-{
-       char buf[WLC_IOCTL_SMLEN];
-       uint len;
-
-       val = htod32(val);
-       len = bcm_mkiovar(name, (char *)(&val), sizeof(val), buf, sizeof(buf));
-       ASSERT(len);
-
-       return (dev_wlc_ioctl(dev, WLC_SET_VAR, buf, len));
-}
-
-#if defined(WL_IW_USE_ISCAN)
-static int
-dev_iw_iovar_setbuf(
-       struct net_device *dev,
-       char *iovar,
-       void *param,
-       int paramlen,
-       void *bufptr,
-       int buflen)
-{
-       int iolen;
-
-       iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
-       ASSERT(iolen);
-
-       if (iolen == 0)
-               return 0;
-
-       return (dev_wlc_ioctl(dev, WLC_SET_VAR, bufptr, iolen));
-}
-
-static int
-dev_iw_iovar_getbuf(
-       struct net_device *dev,
-       char *iovar,
-       void *param,
-       int paramlen,
-       void *bufptr,
-       int buflen)
-{
-       int iolen;
-
-       iolen = bcm_mkiovar(iovar, param, paramlen, bufptr, buflen);
-       ASSERT(iolen);
-
-       return (dev_wlc_ioctl(dev, WLC_GET_VAR, bufptr, buflen));
-}
-#endif 
-
-
-#if WIRELESS_EXT > 17
-static int
-dev_wlc_bufvar_set(
-       struct net_device *dev,
-       char *name,
-       char *buf, int len)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
-       char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
-       static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif 
-       uint buflen;
-
-       buflen = bcm_mkiovar(name, buf, len, ioctlbuf, sizeof(ioctlbuf));
-       ASSERT(buflen);
-
-       return (dev_wlc_ioctl(dev, WLC_SET_VAR, ioctlbuf, buflen));
-}
-#endif 
-
-
-static int
-dev_wlc_bufvar_get(
-       struct net_device *dev,
-       char *name,
-       char *buf, int buflen)
-{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
-       char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#else
-       static char ioctlbuf[MAX_WLIW_IOCTL_LEN];
-#endif 
-       int error;
-       uint len;
-
-       len = bcm_mkiovar(name, NULL, 0, ioctlbuf, sizeof(ioctlbuf));
-       ASSERT(len);
-       error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)ioctlbuf, MAX_WLIW_IOCTL_LEN);
-       if (!error)
-               bcopy(ioctlbuf, buf, buflen);
-
-       return (error);
-}
-
-
-
-static int
-dev_wlc_intvar_get(
-       struct net_device *dev,
-       char *name,
-       int *retval)
-{
-       union {
-               char buf[WLC_IOCTL_SMLEN];
-               int val;
-       } var;
-       int error;
-
-       uint len;
-       uint data_null;
-
-       len = bcm_mkiovar(name, (char *)(&data_null), 0, (char *)(&var), sizeof(var.buf));
-       ASSERT(len);
-       error = dev_wlc_ioctl(dev, WLC_GET_VAR, (void *)&var, len);
-
-       *retval = dtoh32(var.val);
-
-       return (error);
-}
-
-
-#if WIRELESS_EXT > 12
-static int
-wl_iw_set_active_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int as = 0;
-       int error = 0;
-       char *p = extra;
-
-#if defined(WL_IW_USE_ISCAN)
-       if (g_iscan->iscan_state == ISCAN_STATE_IDLE)
-#endif 
-               error = dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &as, sizeof(as));
-#if defined(WL_IW_USE_ISCAN)
-       else
-               g_iscan->scan_flag = as;
-#endif 
-       p += snprintf(p, MAX_WX_STRING, "OK");
-
-       wrqu->data.length = p - extra + 1;
-       return error;
-}
-
-static int
-wl_iw_set_passive_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int ps = 1;
-       int error = 0;
-       char *p = extra;
-
-#if defined(WL_IW_USE_ISCAN)
-       if (g_iscan->iscan_state == ISCAN_STATE_IDLE) {
-#endif 
-
-                
-               if (g_scan_specified_ssid == 0) {
-                       error = dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &ps, sizeof(ps));
-               }
-#if defined(WL_IW_USE_ISCAN)
-       }
-       else
-               g_iscan->scan_flag = ps;
-#endif 
-
-       p += snprintf(p, MAX_WX_STRING, "OK");
-
-       wrqu->data.length = p - extra + 1;
-       return error;
-}
-
-static int
-wl_iw_get_macaddr(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error;
-       char buf[128];
-       struct ether_addr *id;
-       char *p = extra;
-
-       
-       strcpy(buf, "cur_etheraddr");
-       error = dev_wlc_ioctl(dev, WLC_GET_VAR, buf, sizeof(buf));
-       id = (struct ether_addr *) buf;
-       p += snprintf(p, MAX_WX_STRING, "Macaddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
-               id->octet[0], id->octet[1], id->octet[2],
-               id->octet[3], id->octet[4], id->octet[5]);
-       wrqu->data.length = p - extra + 1;
-
-       return error;
-}
-
-
-
-static int
-wl_iw_set_country(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       char country_code[WLC_CNTRY_BUF_SZ];
-       int error = 0;
-       char *p = extra;
-       int country_offset;
-       int country_code_size;
-
-       memset(country_code, 0, sizeof(country_code));
-
-       
-       country_offset = strcspn(extra, " ");
-       country_code_size = strlen(extra) - country_offset;
-
-       
-       if (country_offset != 0) {
-               strncpy(country_code, extra + country_offset +1,
-                       MIN(country_code_size, sizeof(country_code)));
-
-               
-               if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
-                       &country_code, sizeof(country_code))) >= 0) {
-                       p += snprintf(p, MAX_WX_STRING, "OK");
-                       WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
-                       goto exit;
-               }
-       }
-
-       WL_ERROR(("%s: set country %s failed code %d\n", __FUNCTION__, country_code, error));
-       p += snprintf(p, MAX_WX_STRING, "FAIL");
-
-exit:
-       wrqu->data.length = p - extra + 1;
-       return error;
-}
-
-#ifdef CUSTOMER_HW2
-static int
-wl_iw_set_power_mode(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error = 0;
-       char *p = extra;
-       static int  pm = PM_FAST;
-       int  pm_local = PM_OFF;
-       char powermode_val = 0;
-
-       strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
-
-       if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
-
-               WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
-
-               dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm));
-               dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
-       }
-       else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
-
-               WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
-
-
-               dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
-       }
-       else {
-               WL_ERROR(("Unkwown yet power setting, ignored\n"));
-       }
-
-       p += snprintf(p, MAX_WX_STRING, "OK");
-
-       wrqu->data.length = p - extra + 1;
-
-       return error;
-}
-#endif 
-static int
-wl_iw_set_btcoex_dhcp(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error = 0;
-       char *p = extra;
-#ifndef CUSTOMER_HW2
-       static int  pm = PM_FAST;
-       int  pm_local = PM_OFF;
-#endif
-       char powermode_val = 0;
-       char buf_reg66va_dhcp_on[8] = { 66, 00, 00, 00, 0x10, 0x27, 0x00, 0x00 };
-       char buf_reg41va_dhcp_on[8] = { 41, 00, 00, 00, 0x33, 0x00, 0x00, 0x00 };
-       char buf_reg68va_dhcp_on[8] = { 68, 00, 00, 00, 0x90, 0x01, 0x00, 0x00 };
-
-       uint32 regaddr;
-       static uint32 saved_reg66;
-       static uint32 saved_reg41;
-       static uint32 saved_reg68;
-       static bool saved_status = FALSE;
-
-       char buf_flag7_default[8] =   { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-#ifndef CUSTOMER_HW2
-       uint32 temp1, temp2;
-#endif 
-
-       
-#ifdef  CUSTOMER_HW2
-       strncpy((char *)&powermode_val, extra + strlen("BTCOEXMODE") +1, 1);
-#else
-       strncpy((char *)&powermode_val, extra + strlen("POWERMODE") +1, 1);
-#endif
-
-       if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
-
-               WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));
-
-               
-               if ((saved_status == FALSE) &&
-#ifndef CUSTOMER_HW2
-                       (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
-#endif
-                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 66,  &saved_reg66)) &&
-                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 41,  &saved_reg41)) &&
-                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 68,  &saved_reg68)))   {
-                               saved_status = TRUE;
-                               WL_TRACE(("Saved 0x%x 0x%x 0x%x\n", \
-                                       saved_reg66, saved_reg41, saved_reg68));
-
-                               
-#ifndef CUSTOMER_HW2
-                               dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
-#endif
-
-                               
-                               dev_wlc_bufvar_set(dev, "btc_params", \
-                                       (char *)&buf_reg66va_dhcp_on[0], \
-                                                sizeof(buf_reg66va_dhcp_on));
-                               
-                               dev_wlc_bufvar_set(dev, "btc_params", \
-                                       (char *)&buf_reg41va_dhcp_on[0], \
-                                                sizeof(buf_reg41va_dhcp_on));
-                               
-                               dev_wlc_bufvar_set(dev, "btc_params", \
-                                       (char *)&buf_reg68va_dhcp_on[0], \
-                                                sizeof(buf_reg68va_dhcp_on));
-                               
-#ifndef CUSTOMER_HW2
-                               if ((!dev_wlc_intvar_get_reg(dev, "btc_params", 12, &temp1)) &&
-                                       (!dev_wlc_intvar_get_reg(dev, "btc_params", 13, &temp2)))
-                               {
-                                       if ((temp1 != 0) && (temp2 != 0)) {
-#endif
-                                               g_bt->bt_state = BT_DHCP_START;
-                                               g_bt->timer_on = 1;
-                                               mod_timer(&g_bt->timer, g_bt->timer.expires);
-                                               WL_TRACE(("%s enable BT DHCP Timer\n", \
-                                                       __FUNCTION__));
-#ifndef CUSTOMER_HW2
-                                       }
-                               }
-#endif
-               }
-               else if (saved_status == TRUE) {
-                       WL_ERROR(("%s was called w/o DHCP OFF. Continue\n", __FUNCTION__));
-               }
-       }
-#ifdef  CUSTOMER_HW2
-       else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {
-#else
-       else if (strnicmp((char *)&powermode_val, "0", strlen("0")) == 0) {
-#endif
-
-               WL_TRACE(("%s: DHCP session done\n", __FUNCTION__));
-
-               
-#ifndef CUSTOMER_HW2
-               dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
-#endif
-
-               
-               WL_TRACE(("%s disable BT DHCP Timer\n", __FUNCTION__));
-               if (g_bt->timer_on) {
-                       g_bt->timer_on = 0;
-                       del_timer_sync(&g_bt->timer);
-               }
-
-               
-               dev_wlc_bufvar_set(dev, "btc_flags", \
-                               (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
-
-               
-               if (saved_status) {
-                       regaddr = 66;
-                       dev_wlc_intvar_set_reg(dev, "btc_params", \
-                               (char *)&regaddr, (char *)&saved_reg66);
-                       regaddr = 41;
-                       dev_wlc_intvar_set_reg(dev, "btc_params", \
-                               (char *)&regaddr, (char *)&saved_reg41);
-                       regaddr = 68;
-                       dev_wlc_intvar_set_reg(dev, "btc_params", \
-                               (char *)&regaddr, (char *)&saved_reg68);
-               }
-               saved_status = FALSE;
-
-       }
-       else {
-               WL_ERROR(("Unkwown yet power setting, ignored\n"));
-       }
-
-       p += snprintf(p, MAX_WX_STRING, "OK");
-
-       wrqu->data.length = p - extra + 1;
-
-       return error;
-}
-
-int
-wl_format_ssid(char* ssid_buf, uint8* ssid, int ssid_len)
-{
-       int i, c;
-       char *p = ssid_buf;
-
-       if (ssid_len > 32) ssid_len = 32;
-
-       for (i = 0; i < ssid_len; i++) {
-               c = (int)ssid[i];
-               if (c == '\\') {
-                       *p++ = '\\';
-                       *p++ = '\\';
-               } else if (isprint((uchar)c)) {
-                       *p++ = (char)c;
-               } else {
-                       p += sprintf(p, "\\x%02X", c);
-               }
-       }
-       *p = '\0';
-
-       return p - ssid_buf;
-}
-
-static int
-wl_iw_get_link_speed(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error = 0;
-       char *p = extra;
-       static int link_speed;
-
-       
-       if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_RATE, &link_speed, sizeof(link_speed));
-               link_speed *= 500000;
-       }
-
-       p += snprintf(p, MAX_WX_STRING, "LinkSpeed %d", link_speed/1000000);
-
-       wrqu->data.length = p - extra + 1;
-
-       return error;
-}
-
-
-static int
-wl_iw_get_band(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error = -1;
-       char *p = extra;
-       static int band;
-
-       if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band));
-
-               p += snprintf(p, MAX_WX_STRING, "Band %d", band);
-
-               wrqu->data.length = p - extra + 1;
-       }
-       return error;
-}
-
-
-static int
-wl_iw_set_band(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error = -1;
-       char *p = extra;
-       char band;
-
-       if (g_onoff == G_WLAN_SET_ON) {
-
-               band = *(extra + strlen(BAND_SET_CMD) + 1) - '0';
-
-               if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) {
-
-                       
-                       if ((error = dev_wlc_ioctl(dev, WLC_SET_BAND,
-                               &band, sizeof(band))) >= 0) {
-                               p += snprintf(p, MAX_WX_STRING, "OK");
-                               WL_TRACE(("%s: set band %d OK\n", __FUNCTION__, band));
-                               goto exit;
-                       }
-                       else  WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \
-                                       band, error));
-               }
-               else  WL_ERROR(("%s Incorrect band setting, ignored\n", __FUNCTION__));
-       }
-
-       p += snprintf(p, MAX_WX_STRING, "FAIL");
-
-exit:
-       wrqu->data.length = p - extra + 1;
-       return error;
-}
-
-
-static int
-wl_iw_get_rssi(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       static int rssi = 0;
-       static wlc_ssid_t ssid = {0};
-       int error = 0;
-       char *p = extra;
-       static char ssidbuf[SSID_FMT_BUF_LEN];
-       scb_val_t scb_val;
-
-       bzero(&scb_val, sizeof(scb_val_t));
-
-       if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
-               rssi = dtoh32(scb_val.val);
-
-               error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
-
-               ssid.SSID_len = dtoh32(ssid.SSID_len);
-       }
-
-       wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
-       p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi);
-       wrqu->data.length = p - extra + 1;
-
-       return error;
-}
-
-int
-wl_iw_send_priv_event(
-       struct net_device *dev,
-       char *flag
-)
-{
-       union iwreq_data wrqu;
-       char extra[IW_CUSTOM_MAX + 1];
-       int cmd;
-
-       cmd = IWEVCUSTOM;
-       memset(&wrqu, 0, sizeof(wrqu));
-       if (strlen(flag) > sizeof(extra))
-               return -1;
-
-       strcpy(extra, flag);
-       wrqu.data.length = strlen(extra);
-       wireless_send_event(dev, cmd, &wrqu, extra);
-       WL_TRACE(("Send IWEVCUSTOM Event as %s\n", extra));
-
-       return 0;
-}
-
-
-int
-wl_control_wl_start(struct net_device *dev)
-{
-       int ret = 0;
-       wl_iw_t *iw;
-
-       WL_TRACE(("Enter %s \n", __FUNCTION__));
-
-       if (!dev) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return -1;
-       }
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK(iw->pub);
-
-       if (g_onoff == G_WLAN_SET_OFF) {
-               dhd_customer_gpio_wlan_ctrl(WLAN_RESET_ON);
-
-#if defined(BCMLXSDMMC)
-               sdioh_start(NULL, 0);
-#endif
-
-               dhd_dev_reset(dev, 0);
-
-#if defined(BCMLXSDMMC)
-               sdioh_start(NULL, 1);
-#endif
-
-               dhd_dev_init_ioctl(dev);
-
-               g_onoff = G_WLAN_SET_ON;
-       }
-       WL_TRACE(("Exited %s \n", __FUNCTION__));
-
-       MUTEX_UNLOCK(iw->pub);
-       return ret;
-}
-static int
-wl_iw_control_wl_off(
-       struct net_device *dev,
-       struct iw_request_info *info
-)
-{
-       int ret = 0;
-       wl_iw_t *iw;
-
-       WL_TRACE(("Enter %s\n", __FUNCTION__));
-
-       if (!dev) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return -1;
-       }
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK(iw->pub);
-
-#ifdef SOFTAP
-       ap_cfg_running = FALSE;
-#endif 
-
-       if (g_onoff == G_WLAN_SET_ON) {
-               g_onoff = G_WLAN_SET_OFF;
-
-#if defined(WL_IW_USE_ISCAN)
-               g_iscan->iscan_state = ISCAN_STATE_IDLE;
-#endif 
-
-               dhd_dev_reset(dev, 1);
-
-#if defined(WL_IW_USE_ISCAN)
-#if !defined(CSCAN)
-               
-               wl_iw_free_ss_cache();
-               wl_iw_run_ss_cache_timer(0);
-               
-               g_ss_cache_ctrl.m_link_down = 1;
-#endif 
-               memset(g_scan, 0, G_SCAN_RESULTS);
-               g_scan_specified_ssid = 0;
-               
-               g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
-#endif 
-
-#if defined(BCMLXSDMMC)
-               sdioh_stop(NULL);
-#endif
-
-               dhd_customer_gpio_wlan_ctrl(WLAN_RESET_OFF);
-
-               wl_iw_send_priv_event(dev, "STOP");
-
-       }
-
-       MUTEX_UNLOCK(iw->pub);
-
-       WL_TRACE(("Exited %s\n", __FUNCTION__));
-
-       return ret;
-}
-
-static int
-wl_iw_control_wl_on(
-       struct net_device *dev,
-       struct iw_request_info *info
-)
-{
-       int ret = 0;
-
-       WL_TRACE(("Enter %s \n", __FUNCTION__));
-
-       ret = wl_control_wl_start(dev);
-
-       wl_iw_send_priv_event(dev, "START");
-
-#if !defined(CSCAN)
-#ifdef SOFTAP
-       if (!ap_fw_loaded) {
-               wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
-       }
-#else
-       wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
-#endif
-#endif 
-
-       WL_TRACE(("Exited %s \n", __FUNCTION__));
-
-       return ret;
-}
-
-#ifdef SOFTAP
-static struct ap_profile my_ap;
-static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap); 
-static int get_assoc_sta_list(struct net_device *dev, char *buf, int len);
-static int set_ap_mac_list(struct net_device *dev, char *buf);
-#endif /* SOFTAP */
-
-int hex2num(char c)
-{
-       if (c >= '0' && c <= '9')
-               return c - '0';
-       if (c >= 'a' && c <= 'f')
-               return c - 'a' + 10;
-       if (c >= 'A' && c <= 'F')
-               return c - 'A' + 10;
-       return -1;
-}
-
-int hex2byte(const char *hex)
-{
-       int a, b;
-       a = hex2num(*hex++);
-       if (a < 0)
-               return -1;
-       b = hex2num(*hex++);
-       if (b < 0)
-               return -1;
-       return (a << 4) | b;
-}
-
-
-
-int hstr_2_buf(const char *txt, u8 *buf, int len)
-{
-       int i;
-
-       for (i = 0; i < len; i++) {
-               int a, b;
-
-               a = hex2num(*txt++);
-               if (a < 0)
-                       return -1;
-               b = hex2num(*txt++);
-               if (b < 0)
-                       return -1;
-               *buf++ = (a << 4) | b;
-       }
-
-       return 0;
-}
-
-
-
-#if defined(SOFTAP) || defined(CSCAN)
-
-/* parameter type */
-#define PTYPE_STRING   0
-#define PTYPE_INTDEC   1   
-#define PTYPE_INTHEX   2
-#define PTYPE_STR_HEX  3  
-
-int get_parmeter_from_string(
-                       char **str_ptr, const char *token,
-                       int param_type, void  *dst, int param_max_len)
-{
-       char int_str[7] = "0";
-       int parm_str_len;
-       char  *param_str_begin;
-       char  *param_str_end;
-       char  *orig_str = *str_ptr;
-
-       if ((*str_ptr) && !strncmp(*str_ptr, token, strlen(token))) {
-
-               strsep(str_ptr, "=,"); 
-               param_str_begin = *str_ptr;
-               strsep(str_ptr, "=,"); 
-
-               if (*str_ptr == NULL) {
-                       
-                       parm_str_len = strlen(param_str_begin);
-               } else {
-                       param_str_end = *str_ptr-1;  
-                       parm_str_len = param_str_end - param_str_begin;
-               }
-
-               WL_TRACE((" 'token:%s', len:%d, ", token, parm_str_len));
-
-               if (parm_str_len > param_max_len) {
-                       WL_ERROR((" WARNING: extracted param len:%d is > MAX:%d\n",
-                               parm_str_len, param_max_len));
-
-                       parm_str_len = param_max_len;
-               }
-
-               switch (param_type) {
-
-                       case PTYPE_INTDEC: {
-                       
-                               int *pdst_int = dst;
-                               char *eptr;
-                               if (parm_str_len > sizeof(int_str))
-                                        parm_str_len = sizeof(int_str);
-
-                               memcpy(int_str, param_str_begin, parm_str_len);
-
-                               *pdst_int = simple_strtoul(int_str, &eptr, 10);
-
-                               WL_TRACE((" written as integer:%d\n",  *pdst_int));
-                       }
-                       break;
-                       case PTYPE_STR_HEX: {
-                               u8 *buf = dst;
-                               
-                               param_max_len = param_max_len >> 1;  
-                               hstr_2_buf(param_str_begin, buf, param_max_len);
-                               print_buf(buf, param_max_len, 0);
-                       }
-                       break;
-                       default:
-                               
-                               memcpy(dst, param_str_begin, parm_str_len);
-                               *((char *)dst + parm_str_len) = 0; 
-                               WL_ERROR((" written as a string:%s\n", (char *)dst));
-                       break;
-
-               }
-
-               return 0;
-       } else {
-               WL_ERROR(("\n %s: ERROR: can't find token:%s in str:%s \n",
-                       __FUNCTION__, token, orig_str));
-
-        return -1;
-       }
-}
-
-#endif 
-
-
-#ifdef SOFTAP
-int init_ap_profile_from_string(char *param_str, struct ap_profile *ap_cfg)
-{
-       char *str_ptr = param_str;
-       char sub_cmd[16];
-       int ret = 0;
-
-       memset(sub_cmd, 0, sizeof(sub_cmd));
-       memset(ap_cfg, 0, sizeof(struct ap_profile));
-
-       
-       if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=",
-               PTYPE_STRING, sub_cmd, SSID_LEN) != 0) {
-        return -1;
-       }
-       if (strncmp(sub_cmd, "AP_CFG", 6)) {
-          WL_ERROR(("ERROR: sub_cmd:%s != 'AP_CFG'!\n", sub_cmd));
-               return -1;
-       }
-
-       
-       
-       ret = get_parmeter_from_string(&str_ptr, "SSID=", PTYPE_STRING, ap_cfg->ssid, SSID_LEN);
-
-       ret |= get_parmeter_from_string(&str_ptr, "SEC=", PTYPE_STRING,  ap_cfg->sec, SEC_LEN);
-
-       ret |= get_parmeter_from_string(&str_ptr, "KEY=", PTYPE_STRING,  ap_cfg->key, KEY_LEN);
-
-       ret |= get_parmeter_from_string(&str_ptr, "CHANNEL=", PTYPE_INTDEC, &ap_cfg->channel, 5);
-
-       ret |= get_parmeter_from_string(&str_ptr, "PREAMBLE=", PTYPE_INTDEC, &ap_cfg->preamble, 5);
-
-       ret |= get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC,  &ap_cfg->max_scb, 5);
-
-       return ret;
-}
-#endif 
-
-
-
-#ifdef SOFTAP
-static int iwpriv_set_ap_config(struct net_device *dev,
-            struct iw_request_info *info,
-            union iwreq_data *wrqu,
-            char *ext)
-{
-       int res = 0;
-       char  *extra = NULL;
-       struct ap_profile *ap_cfg = &my_ap;
-
-       WL_TRACE(("> Got IWPRIV SET_AP IOCTL: info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
-               info->cmd, info->flags,
-               wrqu->data.pointer, wrqu->data.length));
-
-
-       if (wrqu->data.length != 0) {
-
-               char *str_ptr;
-
-               if (!(extra = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
-                       return -ENOMEM;
-
-               if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
-                       kfree(extra);
-                       return -EFAULT;
-               }
-
-               extra[wrqu->data.length] = 0;
-               WL_SOFTAP((" Got str param in iw_point:\n %s\n", extra));
-
-               memset(ap_cfg, 0, sizeof(struct ap_profile));
-
-               
-
-               str_ptr = extra;
-
-               if ((res = init_ap_profile_from_string(extra, ap_cfg)) < 0) {
-                       WL_ERROR(("%s failed to parse %d\n", __FUNCTION__, res));
-                       kfree(extra);
-                       return -1;
-               }
-
-       } else {
-        
-         WL_ERROR(("IWPRIV argument len = 0 \n"));
-         return -1;
-       }
-
-       if ((res = set_ap_cfg(dev, ap_cfg)) < 0)
-               WL_ERROR(("%s failed to set_ap_cfg %d\n", __FUNCTION__, res));
-
-       kfree(extra);
-
-       return res;
-}
-#endif 
-
-
-
-#ifdef SOFTAP
-static int iwpriv_get_assoc_list(struct net_device *dev,
-        struct iw_request_info *info,
-        union iwreq_data *p_iwrq,
-        char *extra)
-{
-       int i, ret = 0;
-       char mac_buf[256];
-       struct maclist *sta_maclist = (struct maclist *)mac_buf;
-
-       char mac_lst[256];
-       char *p_mac_str;
-
-       WL_TRACE(("\n %s: IWPRIV IOCTL: cmd:%hx, flags:%hx, extra:%p, iwp.len:%d, \
-               iwp.len:%p, iwp.flags:%x  \n", __FUNCTION__, info->cmd, info->flags, \
-               extra, p_iwrq->data.length, p_iwrq->data.pointer, p_iwrq->data.flags));
-
-       WL_SOFTAP(("extra:%s\n", extra));
-       print_buf((u8 *)p_iwrq, 16, 0);
-
-       memset(sta_maclist, 0, sizeof(mac_buf));
-
-       sta_maclist->count = 8;
-
-       WL_TRACE((" net device:%s, buf_sz:%d\n", dev->name, sizeof(mac_buf)));
-       get_assoc_sta_list(dev, mac_buf, 256);
-       WL_TRACE((" got %d stations\n", sta_maclist->count));
-
-       
-       memset(mac_lst, 0, sizeof(mac_lst));
-       p_mac_str = mac_lst;
-
-       for (i = 0; i < 8; i++) {
-               struct ether_addr * id = &sta_maclist->ea[i];
-
-               WL_SOFTAP(("dhd_drv>> sta_mac[%d] :", i));
-               print_buf((unsigned char *)&sta_maclist->ea[i], 6, 0);
-
-               
-               p_mac_str += snprintf(p_mac_str, MAX_WX_STRING,
-                       "Mac[%d]=%02X:%02X:%02X:%02X:%02X:%02X\n", i,
-                       id->octet[0], id->octet[1], id->octet[2],
-                       id->octet[3], id->octet[4], id->octet[5]);
-
-       }
-
-       p_iwrq->data.length = strlen(mac_lst);
-
-       WL_TRACE(("u.pointer:%p\n", p_iwrq->data.pointer));
-       WL_TRACE(("resulting str:\n%s \n len:%d\n\n", mac_lst, p_iwrq->data.length));
-
-       if (p_iwrq->data.length) {
-               if (copy_to_user(p_iwrq->data.pointer, mac_lst, p_iwrq->data.length)) {
-                       WL_ERROR(("%s: Can't copy to user\n", __FUNCTION__));
-                       return -EFAULT;
-               }
-       }
-
-       WL_ERROR(("Exited %s \n", __FUNCTION__));
-       return ret;
-}
-#endif 
-
-
-#ifdef SOFTAP
-static int iwpriv_set_mac_filters(struct net_device *dev,
-        struct iw_request_info *info,
-        union iwreq_data *wrqu,
-        char *ext)
-{
-
-       int i, ret = -1;
-       char  * extra = NULL;
-       u8  macfilt[8][6];
-       int mac_cnt = 0; 
-       char sub_cmd[16];
-
-       WL_TRACE((">>> Got IWPRIV SET_MAC_FILTER IOCTL:  info->cmd:%x, \
-                       info->flags:%x, u.data:%p, u.len:%d\n",
-                       info->cmd, info->flags,
-                       wrqu->data.pointer, wrqu->data.length));
-
-       if (wrqu->data.length != 0) {
-
-               char *str_ptr;
-
-               if (!(extra = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
-                       return -ENOMEM;
-
-               if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
-                       kfree(extra);
-                       return -EFAULT;
-               }
-
-               extra[wrqu->data.length] = 0;
-               WL_SOFTAP((" Got parameter string in iw_point:\n %s \n", extra));
-
-               memset(macfilt, 0, sizeof(macfilt));
-               memset(sub_cmd, 0, sizeof(sub_cmd));
-
-               
-               str_ptr = extra;
-
-               
-          if (get_parmeter_from_string(&str_ptr, "ASCII_CMD=", PTYPE_STRING, sub_cmd, 15) != 0) {
-                goto exit_proc;
-          }
-
-#define MAC_FILT_MAX 8
-          
-               if (strncmp(sub_cmd, "MAC_FLT_W", strlen("MAC_FLT_W"))) {
-                  WL_ERROR(("ERROR: sub_cmd:%s != 'MAC_FLT_W'!\n", sub_cmd));
-                       goto exit_proc;
-               }
-
-               if (get_parmeter_from_string(&str_ptr, "MAC_CNT=",
-                       PTYPE_INTDEC, &mac_cnt, 4) != 0) {
-                       WL_ERROR(("ERROR: MAC_CNT param is missing \n"));
-                       goto exit_proc;
-               }
-
-               if (mac_cnt > MAC_FILT_MAX) {
-                       WL_ERROR(("ERROR: number of MAC filters > MAX\n"));
-                       goto exit_proc;
-               }
-
-               for (i=0; i< mac_cnt; i++)      
-               if (get_parmeter_from_string(&str_ptr, "MAC=",
-                       PTYPE_STR_HEX, macfilt[i], 12) != 0) {
-                       WL_ERROR(("ERROR: MAC_filter[%d] is missing !\n", i));
-                       goto exit_proc;
-               }
-
-               for (i = 0; i < mac_cnt; i++) {
-                  WL_SOFTAP(("mac_filt[%d]:", i));
-                  print_buf(macfilt[i], 6, 0);
-               }
-
-               
-               wrqu->data.pointer = NULL;
-               wrqu->data.length = 0;
-               ret = 0;
-
-       } else {
-        
-         WL_ERROR(("IWPRIV argument len is 0\n"));
-         return -1;
-       }
-
-       exit_proc:
-       kfree(extra);
-       return ret;
-}
-#endif 
-
-#endif 
-
-#if WIRELESS_EXT < 13
-struct iw_request_info
-{
-       __u16           cmd;            
-       __u16           flags;          
-};
-
-typedef int (*iw_handler)(struct net_device *dev,
-                struct iw_request_info *info,
-                void *wrqu,
-                char *extra);
-#endif 
-
-static int
-wl_iw_config_commit(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       void *zwrq,
-       char *extra
-)
-{      
-       wlc_ssid_t ssid;
-       int error;
-       struct sockaddr bssid;
-
-       WL_TRACE(("%s: SIOCSIWCOMMIT\n", dev->name));
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid))))
-               return error;
-
-       ssid.SSID_len = dtoh32(ssid.SSID_len);
-
-       if (!ssid.SSID_len)
-               return 0;
-
-       bzero(&bssid, sizeof(struct sockaddr));
-       if ((error = dev_wlc_ioctl(dev, WLC_REASSOC, &bssid, ETHER_ADDR_LEN))) {
-               WL_ERROR(("%s: WLC_REASSOC to %s failed \n", __FUNCTION__, ssid.SSID));
-               return error;
-       }
-
-       return 0;
-}
-
-static int
-wl_iw_get_name(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       char *cwrq,
-       char *extra
-)
-{
-       WL_TRACE(("%s: SIOCGIWNAME\n", dev->name));
-
-       strcpy(cwrq, "IEEE 802.11-DS");
-
-       return 0;
-}
-
-static int
-wl_iw_set_freq(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_freq *fwrq,
-       char *extra
-)
-{
-       int error, chan;
-       uint sf = 0;
-
-       WL_TRACE(("%s %s: SIOCSIWFREQ : e=%d m=%d\n", __func__, dev->name, fwrq->e, fwrq->m));
-
-#if defined(SOFTAP)
-       if (ap_cfg_running) {
-               WL_TRACE(("%s:>> not executed, 'SOFT_AP is active' \n", __FUNCTION__));
-               return 0;
-       }
-#endif
-
-       
-       if (fwrq->e == 0 && fwrq->m < MAXCHANNEL) 
-       {
-               chan = fwrq->m;
-       }
-       else 
-       {
-               if (fwrq->e >= 6) 
-               {
-                       fwrq->e -= 6;
-                       while (fwrq->e--)
-                               fwrq->m *= 10;
-               } 
-               else if (fwrq->e < 6) 
-               {
-                       while (fwrq->e++ < 6)
-                               fwrq->m /= 10;
-               }
-       
-               if (fwrq->m > 4000 && fwrq->m < 5000)
-                       sf = WF_CHAN_FACTOR_4_G; 
-
-               chan = wf_mhz2channel(fwrq->m, sf);
-       }
-       chan = htod32(chan);    
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan))))
-               return error;
-
-       
-       return -EINPROGRESS;
-}
-
-static int
-wl_iw_get_freq(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_freq *fwrq,
-       char *extra
-)
-{
-       channel_info_t ci;
-       int error;
-
-       WL_TRACE(("%s: SIOCGIWFREQ\n", dev->name));
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
-               return error;
-
-       
-       fwrq->m = dtoh32(ci.hw_channel);
-       fwrq->e = dtoh32(0);
-       return 0;
-}
-
-static int
-wl_iw_set_mode(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       __u32 *uwrq,
-       char *extra
-)
-{
-       int infra = 0, ap = 0, error = 0;
-
-       WL_TRACE(("%s: SIOCSIWMODE\n", dev->name));
-
-       switch (*uwrq) {
-       case IW_MODE_MASTER:
-               infra = ap = 1;
-               break;
-       case IW_MODE_ADHOC:
-       case IW_MODE_AUTO:
-               break;
-       case IW_MODE_INFRA:
-               infra = 1;
-               break;
-       default:
-               return -EINVAL;
-       }
-       infra = htod32(infra);
-       ap = htod32(ap);
-
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_INFRA, &infra, sizeof(infra))) ||
-           (error = dev_wlc_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap))))
-               return error;
-
-       
-       return -EINPROGRESS;
-}
-
-static int
-wl_iw_get_mode(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       __u32 *uwrq,
-       char *extra
-)
-{
-       int error, infra = 0, ap = 0;
-
-       WL_TRACE(("%s: SIOCGIWMODE\n", dev->name));
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra))) ||
-           (error = dev_wlc_ioctl(dev, WLC_GET_AP, &ap, sizeof(ap))))
-               return error;
-
-       infra = dtoh32(infra);
-       ap = dtoh32(ap);
-       *uwrq = infra ? ap ? IW_MODE_MASTER : IW_MODE_INFRA : IW_MODE_ADHOC;
-
-       return 0;
-}
-
-static int
-wl_iw_set_sens(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       __u32 *uwrq,
-       char *extra
-)
-{
-       WL_TRACE(("%s: SIOCSIWSENS\n", dev->name));
-       return 0;
-}
-
-static int
-wl_iw_get_sens(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       static int rssi = 0;
-       static wlc_ssid_t ssid = {0};
-       int error = 0;
-       static char ssidbuf[SSID_FMT_BUF_LEN];
-       scb_val_t scb_val;
-
-       WL_TRACE(("%s: SIOCGIWSENS\n", dev->name));
-       
-       bzero(&scb_val, sizeof(scb_val_t));
-       
-       if (g_onoff == G_WLAN_SET_ON) {
-               error = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t));
-               if (error) {
-                       WL_ERROR(("%s: Fails %d\n", __FUNCTION__, error));
-                       return error;
-               }
-               rssi = dtoh32(scb_val.val);
-               
-               error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid));
-               if (!error) {
-                       ssid.SSID_len = dtoh32(ssid.SSID_len);
-                       wl_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len));
-               }
-       }
-       
-       wrqu->sens.value = -rssi;
-    
-       return error;
-}
-
-static int
-wl_iw_get_range(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       struct iw_range *range = (struct iw_range *) extra;
-       wl_uint32_list_t *list;
-       wl_rateset_t rateset;
-       int8 *channels;
-       int error, i, k;
-       uint sf, ch;
-
-       int phytype;
-       int bw_cap = 0, sgi_tx = 0, nmode = 0;
-       channel_info_t ci;
-       uint8 nrate_list2copy = 0;
-       uint16 nrate_list[4][8] = { {13, 26, 39, 52, 78, 104, 117, 130},
-               {14, 29, 43, 58, 87, 116, 130, 144},
-               {27, 54, 81, 108, 162, 216, 243, 270},
-               {30, 60, 90, 120, 180, 240, 270, 300}};
-
-       WL_TRACE(("%s: SIOCGIWRANGE\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       channels = kmalloc((MAXCHANNEL+1)*4, GFP_KERNEL);
-       if (!channels) {
-               WL_ERROR(("Could not alloc channels\n"));
-               return -ENOMEM;
-       }
-       list = (wl_uint32_list_t *)channels;
-
-       dwrq->length = sizeof(struct iw_range);
-       memset(range, 0, sizeof(range));
-
-       
-       range->min_nwid = range->max_nwid = 0;
-
-       
-       list->count = htod32(MAXCHANNEL);
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, (MAXCHANNEL+1)*4))) {
-               kfree(channels);
-               return error;
-       }
-       for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
-               range->freq[i].i = dtoh32(list->element[i]);
-
-               ch = dtoh32(list->element[i]);
-               if (ch <= CH_MAX_2G_CHANNEL)
-                       sf = WF_CHAN_FACTOR_2_4_G;
-               else
-                       sf = WF_CHAN_FACTOR_5_G;
-
-               range->freq[i].m = wf_channel2mhz(ch, sf);
-               range->freq[i].e = 6;
-       }
-       range->num_frequency = range->num_channels = i;
-
-       
-       range->max_qual.qual = 5;
-       
-       range->max_qual.level = 0x100 - 200;    
-       
-       range->max_qual.noise = 0x100 - 200;    
-       
-       range->sensitivity = 65535;
-
-#if WIRELESS_EXT > 11
-       
-       range->avg_qual.qual = 3;
-       
-       range->avg_qual.level = 0x100 + WL_IW_RSSI_GOOD;
-       
-       range->avg_qual.noise = 0x100 - 75;     
-#endif 
-
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset)))) {
-               kfree(channels);
-               return error;
-       }
-       rateset.count = dtoh32(rateset.count);
-       range->num_bitrates = rateset.count;
-       for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++)
-               range->bitrate[i] = (rateset.rates[i]& 0x7f) * 500000; 
-       dev_wlc_intvar_get(dev, "nmode", &nmode);
-       dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &phytype, sizeof(phytype));
-
-       if (nmode == 1 && phytype == WLC_PHY_TYPE_SSN) {
-               dev_wlc_intvar_get(dev, "mimo_bw_cap", &bw_cap);
-               dev_wlc_intvar_get(dev, "sgi_tx", &sgi_tx);
-               dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(channel_info_t));
-               ci.hw_channel = dtoh32(ci.hw_channel);
-
-               if (bw_cap == 0 ||
-                       (bw_cap == 2 && ci.hw_channel <= 14)) {
-                       if (sgi_tx == 0)
-                               nrate_list2copy = 0;
-                       else
-                               nrate_list2copy = 1;
-               }
-               if (bw_cap == 1 ||
-                       (bw_cap == 2 && ci.hw_channel >= 36)) {
-                       if (sgi_tx == 0)
-                               nrate_list2copy = 2;
-                       else
-                               nrate_list2copy = 3;
-               }
-               range->num_bitrates += 8;
-               for (k = 0; i < range->num_bitrates; k++, i++) {
-                       
-                       range->bitrate[i] = (nrate_list[nrate_list2copy][k]) * 500000;
-               }
-       }
-
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i)))) {
-               kfree(channels);
-               return error;
-       }
-       i = dtoh32(i);
-       if (i == WLC_PHY_TYPE_A)
-               range->throughput = 24000000;   
-       else
-               range->throughput = 1500000;    
-
-       
-       range->min_rts = 0;
-       range->max_rts = 2347;
-       range->min_frag = 256;
-       range->max_frag = 2346;
-
-       range->max_encoding_tokens = DOT11_MAX_DEFAULT_KEYS;
-       range->num_encoding_sizes = 4;
-       range->encoding_size[0] = WEP1_KEY_SIZE;
-       range->encoding_size[1] = WEP128_KEY_SIZE;
-#if WIRELESS_EXT > 17
-       range->encoding_size[2] = TKIP_KEY_SIZE;
-#else
-       range->encoding_size[2] = 0;
-#endif
-       range->encoding_size[3] = AES_KEY_SIZE;
-
-       
-       range->min_pmp = 0;
-       range->max_pmp = 0;
-       range->min_pmt = 0;
-       range->max_pmt = 0;
-       range->pmp_flags = 0;
-       range->pm_capa = 0;
-
-       
-       range->num_txpower = 2;
-       range->txpower[0] = 1;
-       range->txpower[1] = 255;
-       range->txpower_capa = IW_TXPOW_MWATT;
-
-#if WIRELESS_EXT > 10
-       range->we_version_compiled = WIRELESS_EXT;
-       range->we_version_source = 19;
-
-       
-       range->retry_capa = IW_RETRY_LIMIT;
-       range->retry_flags = IW_RETRY_LIMIT;
-       range->r_time_flags = 0;
-       
-       range->min_retry = 1;
-       range->max_retry = 255;
-       
-       range->min_r_time = 0;
-       range->max_r_time = 0;
-#endif 
-
-#if WIRELESS_EXT > 17
-       range->enc_capa = IW_ENC_CAPA_WPA;
-       range->enc_capa |= IW_ENC_CAPA_CIPHER_TKIP;
-       range->enc_capa |= IW_ENC_CAPA_CIPHER_CCMP;
-#ifdef BCMWPA2
-       range->enc_capa |= IW_ENC_CAPA_WPA2;
-#endif
-
-       
-       IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
-       
-       IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
-       IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
-       IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP);
-       IW_EVENT_CAPA_SET(range->event_capa, IWEVMICHAELMICFAILURE);
-#ifdef BCMWPA2
-       IW_EVENT_CAPA_SET(range->event_capa, IWEVPMKIDCAND);
-#endif
-#endif 
-
-       kfree(channels);
-
-       return 0;
-}
-
-static int
-rssi_to_qual(int rssi)
-{
-       if (rssi <= WL_IW_RSSI_NO_SIGNAL)
-               return 0;
-       else if (rssi <= WL_IW_RSSI_VERY_LOW)
-               return 1;
-       else if (rssi <= WL_IW_RSSI_LOW)
-               return 2;
-       else if (rssi <= WL_IW_RSSI_GOOD)
-               return 3;
-       else if (rssi <= WL_IW_RSSI_VERY_GOOD)
-               return 4;
-       else
-               return 5;
-}
-
-static int
-wl_iw_set_spy(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-       struct sockaddr *addr = (struct sockaddr *) extra;
-       int i;
-
-       WL_TRACE(("%s: SIOCSIWSPY\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       iw->spy_num = MIN(ARRAYSIZE(iw->spy_addr), dwrq->length);
-       for (i = 0; i < iw->spy_num; i++)
-               memcpy(&iw->spy_addr[i], addr[i].sa_data, ETHER_ADDR_LEN);
-       memset(iw->spy_qual, 0, sizeof(iw->spy_qual));
-
-       return 0;
-}
-
-static int
-wl_iw_get_spy(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-       struct sockaddr *addr = (struct sockaddr *) extra;
-       struct iw_quality *qual = (struct iw_quality *) &addr[iw->spy_num];
-       int i;
-
-       WL_TRACE(("%s: SIOCGIWSPY\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       dwrq->length = iw->spy_num;
-       for (i = 0; i < iw->spy_num; i++) {
-               memcpy(addr[i].sa_data, &iw->spy_addr[i], ETHER_ADDR_LEN);
-               addr[i].sa_family = AF_UNIX;
-               memcpy(&qual[i], &iw->spy_qual[i], sizeof(struct iw_quality));
-               iw->spy_qual[i].updated = 0;
-       }
-
-       return 0;
-}
-
-static int
-wl_iw_set_wap(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct sockaddr *awrq,
-       char *extra
-)
-{
-       int error = -EINVAL;
-       wl_join_params_t join_params;
-
-       WL_TRACE(("%s: SIOCSIWAP\n", dev->name));
-
-       if (awrq->sa_family != ARPHRD_ETHER) {
-               WL_ERROR(("Invalid Header...sa_family\n"));
-               return -EINVAL;
-       }
-
-       
-       if (ETHER_ISBCAST(awrq->sa_data) || ETHER_ISNULLADDR(awrq->sa_data)) {
-               scb_val_t scbval;
-               
-               bzero(&scbval, sizeof(scb_val_t));
-               
-               (void) dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t));
-               return 0;
-       }
-
-
-       
-       memset(&join_params, 0, sizeof(join_params));
-
-       memcpy(join_params.ssid.SSID, g_ssid.SSID, g_ssid.SSID_len);
-       join_params.ssid.SSID_len = htod32(g_ssid.SSID_len);
-       memcpy(&join_params.params.bssid, awrq->sa_data, ETHER_ADDR_LEN);
-
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &join_params, sizeof(join_params)))) {
-               WL_ERROR(("Invalid ioctl data.\n"));
-               return error;
-       }
-
-       
-       memset(&g_ssid, 0, sizeof(g_ssid));
-       return 0;
-}
-
-static int
-wl_iw_get_wap(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct sockaddr *awrq,
-       char *extra
-)
-{
-       WL_TRACE(("%s: SIOCGIWAP\n", dev->name));
-
-       awrq->sa_family = ARPHRD_ETHER;
-       memset(awrq->sa_data, 0, ETHER_ADDR_LEN);
-
-       
-       (void) dev_wlc_ioctl(dev, WLC_GET_BSSID, awrq->sa_data, ETHER_ADDR_LEN);
-
-       return 0;
-}
-
-#if WIRELESS_EXT > 17
-static int
-wl_iw_mlme(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct sockaddr *awrq,
-       char *extra
-)
-{
-       struct iw_mlme *mlme;
-       scb_val_t scbval;
-       int error  = -EINVAL;
-
-       WL_TRACE(("%s: SIOCSIWMLME DISASSOC/DEAUTH\n", dev->name));
-
-       mlme = (struct iw_mlme *)extra;
-       if (mlme == NULL) {
-               WL_ERROR(("Invalid ioctl data.\n"));
-               return error;
-       }
-
-       scbval.val = mlme->reason_code;
-       bcopy(&mlme->addr.sa_data, &scbval.ea, ETHER_ADDR_LEN);
-
-       if (mlme->cmd == IW_MLME_DISASSOC) {
-               scbval.val = htod32(scbval.val);
-               error = dev_wlc_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t));
-       }
-       else if (mlme->cmd == IW_MLME_DEAUTH) {
-               scbval.val = htod32(scbval.val);
-               error = dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
-                       sizeof(scb_val_t));
-       }
-       else {
-               WL_ERROR(("Invalid ioctl data.\n"));
-               return error;
-       }
-
-       return error;
-}
-#endif 
-
-static int
-wl_iw_get_aplist(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_scan_results_t *list;
-       struct sockaddr *addr = (struct sockaddr *) extra;
-       struct iw_quality qual[IW_MAX_AP];
-       wl_bss_info_t *bi = NULL;
-       int error, i;
-       uint buflen = dwrq->length;
-
-       WL_TRACE(("%s: SIOCGIWAPLIST\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       
-       list = kmalloc(buflen, GFP_KERNEL);
-       if (!list)
-               return -ENOMEM;
-       memset(list, 0, buflen);
-       list->buflen = htod32(buflen);
-       if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, buflen))) {
-               WL_ERROR(("%d: Scan results error %d\n", __LINE__, error));
-               kfree(list);
-               return error;
-       }
-       list->buflen = dtoh32(list->buflen);
-       list->version = dtoh32(list->version);
-       list->count = dtoh32(list->count);
-       if (list->version != WL_BSS_INFO_VERSION) {
-               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
-                        __FUNCTION__, list->version));
-               kfree(list);
-               return -EINVAL;
-       }
-
-       for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
-               bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
-               ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
-                       buflen));
-
-               
-               if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
-                       continue;
-
-               
-               memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
-               addr[dwrq->length].sa_family = ARPHRD_ETHER;
-               qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
-               qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
-               qual[dwrq->length].noise = 0x100 + bi->phy_noise;
-
-               
-#if WIRELESS_EXT > 18
-               qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
-#else
-               qual[dwrq->length].updated = 7;
-#endif 
-
-               dwrq->length++;
-       }
-
-       kfree(list);
-
-       if (dwrq->length) {
-               memcpy(&addr[dwrq->length], qual, sizeof(struct iw_quality) * dwrq->length);
-               
-               dwrq->flags = 1;
-       }
-
-       return 0;
-}
-
-#ifdef WL_IW_USE_ISCAN
-static int
-wl_iw_iscan_get_aplist(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_scan_results_t *list;
-       iscan_buf_t * buf;
-       iscan_info_t *iscan = g_iscan;
-
-       struct sockaddr *addr = (struct sockaddr *) extra;
-       struct iw_quality qual[IW_MAX_AP];
-       wl_bss_info_t *bi = NULL;
-       int i;
-
-       WL_TRACE(("%s: SIOCGIWAPLIST\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       if ((!iscan) || (iscan->sysioc_pid < 0)) {
-               return wl_iw_get_aplist(dev, info, dwrq, extra);
-       }
-
-       buf = iscan->list_hdr;
-       
-       while (buf) {
-               list = &((wl_iscan_results_t*)buf->iscan_buf)->results;
-               if (list->version != WL_BSS_INFO_VERSION) {
-                       WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
-                               __FUNCTION__, list->version));
-                       return -EINVAL;
-               }
-
-               bi = NULL;
-               for (i = 0, dwrq->length = 0; i < list->count && dwrq->length < IW_MAX_AP; i++) {
-                       bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length))
-                                 : list->bss_info;
-                       ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
-                               WLC_IW_ISCAN_MAXLEN));
-
-                       
-                       if (!(dtoh16(bi->capability) & DOT11_CAP_ESS))
-                               continue;
-
-                       
-                       memcpy(addr[dwrq->length].sa_data, &bi->BSSID, ETHER_ADDR_LEN);
-                       addr[dwrq->length].sa_family = ARPHRD_ETHER;
-                       qual[dwrq->length].qual = rssi_to_qual(dtoh16(bi->RSSI));
-                       qual[dwrq->length].level = 0x100 + dtoh16(bi->RSSI);
-                       qual[dwrq->length].noise = 0x100 + bi->phy_noise;
-
-                       
-#if WIRELESS_EXT > 18
-                       qual[dwrq->length].updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
-#else
-                       qual[dwrq->length].updated = 7;
-#endif 
-
-                       dwrq->length++;
-               }
-               buf = buf->next;
-       }
-       if (dwrq->length) {
-               memcpy(&addr[dwrq->length], qual, sizeof(struct iw_quality) * dwrq->length);
-               
-               dwrq->flags = 1;
-       }
-
-       return 0;
-}
-
-static int
-wl_iw_iscan_prep(wl_scan_params_t *params, wlc_ssid_t *ssid)
-{
-       int err = 0;
-
-       memcpy(&params->bssid, &ether_bcast, ETHER_ADDR_LEN);
-       params->bss_type = DOT11_BSSTYPE_ANY;
-       params->scan_type = 0;
-       params->nprobes = -1;
-       params->active_time = -1;
-       params->passive_time = -1;
-       params->home_time = -1;
-       params->channel_num = 0;
-
-       params->nprobes = htod32(params->nprobes);
-       params->active_time = htod32(params->active_time);
-       params->passive_time = htod32(params->passive_time);
-       params->home_time = htod32(params->home_time);
-       if (ssid && ssid->SSID_len)
-               memcpy(&params->ssid, ssid, sizeof(wlc_ssid_t));
-
-       return err;
-}
-
-static int
-wl_iw_iscan(iscan_info_t *iscan, wlc_ssid_t *ssid, uint16 action)
-{
-       int err = 0;
-
-       iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
-       iscan->iscan_ex_params_p->action = htod16(action);
-       iscan->iscan_ex_params_p->scan_duration = htod16(0);
-
-       WL_SCAN(("%s : nprobes=%d\n", __FUNCTION__, iscan->iscan_ex_params_p->params.nprobes));
-       WL_SCAN(("active_time=%d\n", iscan->iscan_ex_params_p->params.active_time));
-       WL_SCAN(("passive_time=%d\n", iscan->iscan_ex_params_p->params.passive_time));
-       WL_SCAN(("home_time=%d\n", iscan->iscan_ex_params_p->params.home_time));
-       WL_SCAN(("scan_type=%d\n", iscan->iscan_ex_params_p->params.scan_type));
-       WL_SCAN(("bss_type=%d\n", iscan->iscan_ex_params_p->params.bss_type));
-
-       
-       (void) dev_iw_iovar_setbuf(iscan->dev, "iscan", iscan->iscan_ex_params_p, \
-               iscan->iscan_ex_param_size, iscan->ioctlbuf, sizeof(iscan->ioctlbuf));
-
-       return err;
-}
-
-static void
-wl_iw_timerfunc(ulong data)
-{
-       iscan_info_t *iscan = (iscan_info_t *)data;
-       if (iscan) {
-               iscan->timer_on = 0;
-               if (iscan->iscan_state != ISCAN_STATE_IDLE) {
-                       WL_TRACE(("timer trigger\n"));
-                       up(&iscan->sysioc_sem);
-               }
-       }
-}
-static void wl_iw_set_event_mask(struct net_device *dev)
-{
-       char eventmask[WL_EVENTING_MASK_LEN];
-       char iovbuf[WL_EVENTING_MASK_LEN + 12]; 
-
-       dev_iw_iovar_getbuf(dev, "event_msgs", "", 0, iovbuf, sizeof(iovbuf));
-       bcopy(iovbuf, eventmask, WL_EVENTING_MASK_LEN);
-       setbit(eventmask, WLC_E_SCAN_COMPLETE);
-       dev_iw_iovar_setbuf(dev, "event_msgs", eventmask, WL_EVENTING_MASK_LEN,
-               iovbuf, sizeof(iovbuf));
-}
-
-static uint32
-wl_iw_iscan_get(iscan_info_t *iscan)
-{
-       iscan_buf_t * buf;
-       iscan_buf_t * ptr;
-       wl_iscan_results_t * list_buf;
-       wl_iscan_results_t list;
-       wl_scan_results_t *results;
-       uint32 status;
-
-       
-       MUTEX_LOCK_WL_SCAN_SET();
-       if (iscan->list_cur) {
-               buf = iscan->list_cur;
-               iscan->list_cur = buf->next;
-       }
-       else {
-               buf = kmalloc(sizeof(iscan_buf_t), GFP_KERNEL);
-               if (!buf) {
-                       WL_ERROR(("%s can't alloc iscan_buf_t : going to abort currect iscan\n", \
-                                               __FUNCTION__));
-                       MUTEX_UNLOCK_WL_SCAN_SET();
-                       return WL_SCAN_RESULTS_NO_MEM;
-               }
-               buf->next = NULL;
-               if (!iscan->list_hdr)
-                       iscan->list_hdr = buf;
-               else {
-                       ptr = iscan->list_hdr;
-                       while (ptr->next) {
-                               ptr = ptr->next;
-                       }
-                       ptr->next = buf;
-               }
-       }
-       memset(buf->iscan_buf, 0, WLC_IW_ISCAN_MAXLEN);
-       list_buf = (wl_iscan_results_t*)buf->iscan_buf;
-       results = &list_buf->results;
-       results->buflen = WL_ISCAN_RESULTS_FIXED_SIZE;
-       results->version = 0;
-       results->count = 0;
-
-       memset(&list, 0, sizeof(list));
-       list.results.buflen = htod32(WLC_IW_ISCAN_MAXLEN);
-       (void) dev_iw_iovar_getbuf(
-               iscan->dev,
-               "iscanresults",
-               &list,
-               WL_ISCAN_RESULTS_FIXED_SIZE,
-               buf->iscan_buf,
-               WLC_IW_ISCAN_MAXLEN);
-       results->buflen = dtoh32(results->buflen);
-       results->version = dtoh32(results->version);
-       results->count = dtoh32(results->count);
-       WL_TRACE(("%s: results->count = %d\n", __func__, results->count));
-
-       //WL_TRACE(("results->buflen = %d\n", results->buflen));
-       status = dtoh32(list_buf->status);
-       MUTEX_UNLOCK_WL_SCAN_SET();
-       return status;
-}
-
-static void wl_iw_force_specific_scan(iscan_info_t *iscan)
-{
-       WL_TRACE(("%s force Specific SCAN for %s\n", __FUNCTION__, g_specific_ssid.SSID));
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-       rtnl_lock();
-#endif
-
-       (void) dev_wlc_ioctl(iscan->dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid));
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-       rtnl_unlock();
-#endif
-}
-static void wl_iw_send_scan_complete(iscan_info_t *iscan)
-{
-#ifndef SANDGATE2G
-       union iwreq_data wrqu;
-
-#if !defined(CSCAN)
-       if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED)
-               g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_READY;
-#endif 
-       memset(&wrqu, 0, sizeof(wrqu));
-       wireless_send_event(iscan->dev, SIOCGIWSCAN, &wrqu, NULL);
-       WL_TRACE(("Send Event ISCAN complete\n"));
-#endif 
-}
-static int
-_iscan_sysioc_thread(void *data)
-{
-       uint32 status;
-       iscan_info_t *iscan = (iscan_info_t *)data;
-       static bool iscan_pass_abort = FALSE;
-       DAEMONIZE("iscan_sysioc");
-
-       status = WL_SCAN_RESULTS_PARTIAL;
-       while (down_interruptible(&iscan->sysioc_sem) == 0) {
-
-#if defined(SOFTAP)
-               if (ap_cfg_running) {
-                WL_TRACE(("%s skipping SCAN ops in AP mode !!!\n", __FUNCTION__));
-                continue;
-               }
-#endif 
-               if (iscan->timer_on) {
-                       del_timer(&iscan->timer);
-                       iscan->timer_on = 0;
-               }
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-               rtnl_lock();
-#endif
-               status = wl_iw_iscan_get(iscan);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-               rtnl_unlock();
-#endif
-       if  (g_scan_specified_ssid && (iscan_pass_abort == TRUE)) {
-               WL_TRACE(("%s Get results from specific scan status=%d\n", __FUNCTION__, status));
-                       wl_iw_send_scan_complete(iscan);
-                       iscan_pass_abort = FALSE;
-                       status  = -1;
-               }
-
-               switch (status) {
-                       case WL_SCAN_RESULTS_PARTIAL:
-                               WL_TRACE(("iscanresults incomplete\n"));
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-                               rtnl_lock();
-#endif
-                               
-                               wl_iw_iscan(iscan, NULL, WL_SCAN_ACTION_CONTINUE);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-                               rtnl_unlock();
-#endif
-                               
-                               mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
-                               iscan->timer_on = 1;
-                               break;
-                       case WL_SCAN_RESULTS_SUCCESS:
-                               WL_TRACE(("iscanresults complete\n"));
-                               iscan->iscan_state = ISCAN_STATE_IDLE;
-                               wl_iw_send_scan_complete(iscan);
-                               break;
-                       case WL_SCAN_RESULTS_PENDING:
-                               WL_TRACE(("iscanresults pending\n"));
-                               
-                               mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
-                               iscan->timer_on = 1;
-                               break;
-                       case WL_SCAN_RESULTS_ABORTED:
-                               WL_TRACE(("iscanresults aborted\n"));
-                               iscan->iscan_state = ISCAN_STATE_IDLE;
-                               if (g_scan_specified_ssid == 0)
-                                       wl_iw_send_scan_complete(iscan);
-                               else {
-                                       iscan_pass_abort = TRUE;
-                                       wl_iw_force_specific_scan(iscan);
-                               }
-                               break;
-                       case WL_SCAN_RESULTS_NO_MEM:
-                               WL_TRACE(("iscanresults can't alloc memory: skip\n"));
-                               iscan->iscan_state = ISCAN_STATE_IDLE;
-                               break;
-                       default:
-                               WL_TRACE(("iscanresults returned unknown status %d\n", status));
-                               break;
-                }
-       }
-
-       if (iscan->timer_on) {
-               del_timer(&iscan->timer);
-               iscan->timer_on = 0;
-       }
-       complete_and_exit(&iscan->sysioc_exited, 0);
-}
-#endif 
-
-#if !defined(CSCAN)
-
-static void
-wl_iw_set_ss_cache_timer_flag(void)
-{
-       g_ss_cache_ctrl.m_timer_expired = 1;
-       //WL_TRACE(("%s called\n", __FUNCTION__));
-}
-
-static int
-wl_iw_init_ss_cache_ctrl(void)
-{
-       WL_TRACE(("%s :\n", __FUNCTION__));
-       g_ss_cache_ctrl.m_prev_scan_mode = 0;
-       g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-       g_ss_cache_ctrl.m_cache_head = NULL;
-       g_ss_cache_ctrl.m_link_down = 0;
-       g_ss_cache_ctrl.m_timer_expired = 0;
-       memset(g_ss_cache_ctrl.m_active_bssid, 0, ETHER_ADDR_LEN);
-
-       g_ss_cache_ctrl.m_timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
-       if (!g_ss_cache_ctrl.m_timer) {
-               return -ENOMEM;
-       }
-       g_ss_cache_ctrl.m_timer->function = (void *)wl_iw_set_ss_cache_timer_flag;
-       init_timer(g_ss_cache_ctrl.m_timer);
-
-       return 0;
-}
-
-
-
-static void
-wl_iw_free_ss_cache(void)
-{
-       wl_iw_ss_cache_t *node, *cur;
-       wl_iw_ss_cache_t **spec_scan_head;
-
-       WL_TRACE(("%s called\n", __FUNCTION__));
-
-       MUTEX_LOCK_WL_SCAN_SET();
-       spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
-       node = *spec_scan_head;
-
-       for (;node;) {
-               WL_TRACE(("%s : SSID - %s\n", __FUNCTION__, node->bss_info->SSID));
-               cur = node;
-               node = cur->next;
-               kfree(cur);
-       }
-       *spec_scan_head = NULL;
-       MUTEX_UNLOCK_WL_SCAN_SET();
-}
-
-
-
-static int
-wl_iw_run_ss_cache_timer(int kick_off)
-{
-       struct timer_list **timer;
-
-       timer = &g_ss_cache_ctrl.m_timer;
-
-       if (*timer) {
-               if (kick_off) {
-                       (*timer)->expires = jiffies + 30000 * HZ / 1000;        
-                       add_timer(*timer);
-                       //WL_TRACE(("%s : timer starts \n", __FUNCTION__));
-               } else {
-                       del_timer_sync(*timer);
-                       //WL_TRACE(("%s : timer stops \n", __FUNCTION__));
-               }
-       }
-
-       return 0;
-}
-
-
-void
-wl_iw_release_ss_cache_ctrl(void)
-{
-       WL_TRACE(("%s :\n", __FUNCTION__));
-       wl_iw_free_ss_cache();
-       wl_iw_run_ss_cache_timer(0);
-       if (g_ss_cache_ctrl.m_timer) {
-               kfree(g_ss_cache_ctrl.m_timer);
-       }
-}
-
-
-
-static void
-wl_iw_reset_ss_cache(void)
-{
-       wl_iw_ss_cache_t *node, *prev, *cur;
-       wl_iw_ss_cache_t **spec_scan_head;
-
-       MUTEX_LOCK_WL_SCAN_SET();
-       spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
-       node = *spec_scan_head;
-       prev = node;
-
-       for (;node;) {
-               WL_TRACE(("%s : node SSID %s \n", __FUNCTION__, node->bss_info->SSID));
-               if (!node->dirty) {
-                       cur = node;
-                       if (cur == *spec_scan_head) {
-                               *spec_scan_head = cur->next;
-                               prev = *spec_scan_head;
-                       }
-                       else {
-                               prev->next = cur->next;
-                       }
-                       node = cur->next;
-
-                       WL_TRACE(("%s : Del node : SSID %s\n", __FUNCTION__, cur->bss_info->SSID));
-                       kfree(cur);
-                       continue;
-               }
-
-               node->dirty = 0;
-               prev = node;
-               node = node->next;
-       }
-       MUTEX_UNLOCK_WL_SCAN_SET();
-}
-
-
-static int
-wl_iw_add_bss_to_ss_cache(wl_scan_results_t *ss_list)
-{
-
-       wl_iw_ss_cache_t *node, *prev, *leaf;
-       wl_iw_ss_cache_t **spec_scan_head;
-       wl_bss_info_t *bi = NULL;
-       int i;
-
-       
-       if (!ss_list->count) {
-               return 0;
-       }
-
-       MUTEX_LOCK_WL_SCAN_SET();
-       spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
-       for (i = 0; i < ss_list->count; i++) {
-
-               node = *spec_scan_head;
-               prev = node;
-
-               bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : ss_list->bss_info;
-
-               WL_TRACE(("%s : find %d with specific SSID %s\n", __FUNCTION__, i, bi->SSID));
-               for (;node;) {
-                       if (!memcmp(&node->bss_info->BSSID, &bi->BSSID, ETHER_ADDR_LEN)) {
-                               
-                               WL_TRACE(("dirty marked : SSID %s\n", bi->SSID));
-                               node->dirty = 1;
-                               break;
-                       }
-                       prev = node;
-                       node = node->next;
-               }
-
-               if (node) {
-                       continue;
-               }
-               leaf = kmalloc(bi->length + WLC_IW_SS_CACHE_CTRL_FIELD_MAXLEN, GFP_KERNEL);
-               if (!leaf) {
-                       MUTEX_UNLOCK_WL_SCAN_SET();
-                       return -ENOMEM;
-               }
-
-               memcpy(leaf->bss_info, bi, bi->length);
-               leaf->next = NULL;
-               leaf->dirty = 1;
-               leaf->count = 1;
-               leaf->version = ss_list->version;
-
-               if (!prev) {
-                       *spec_scan_head = leaf;
-               }
-               else {
-                       prev->next = leaf;
-               }
-       }
-       MUTEX_UNLOCK_WL_SCAN_SET();
-       return 0;
-
-}
-
-
-static int
-wl_iw_merge_scan_cache(struct iw_request_info *info, char *extra, uint buflen_from_user,
-__u16 *merged_len)
-{
-       wl_iw_ss_cache_t *node;
-       wl_scan_results_t *list_merge;
-
-       MUTEX_LOCK_WL_SCAN_SET();
-       node = g_ss_cache_ctrl.m_cache_head;
-       for (;node;) {
-               list_merge = (wl_scan_results_t *)node;
-               WL_TRACE(("%s: Cached Specific APs list=%d\n", __FUNCTION__, list_merge->count));
-               if (buflen_from_user - *merged_len > 0) {
-                       *merged_len += (__u16) wl_iw_get_scan_prep(list_merge, info,
-                               extra + *merged_len, buflen_from_user - *merged_len);
-               }
-               else {
-                       WL_TRACE(("%s: exit with break\n", __FUNCTION__));
-                       break;
-               }
-               node = node->next;
-       }
-       MUTEX_UNLOCK_WL_SCAN_SET();
-       return 0;
-}
-
-
-static int
-wl_iw_delete_bss_from_ss_cache(void *addr)
-{
-
-       wl_iw_ss_cache_t *node, *prev;
-       wl_iw_ss_cache_t **spec_scan_head;
-
-       MUTEX_LOCK_WL_SCAN_SET();
-       spec_scan_head = &g_ss_cache_ctrl.m_cache_head;
-       node = *spec_scan_head;
-       prev = node;
-       for (;node;) {
-               if (!memcmp(&node->bss_info->BSSID, addr, ETHER_ADDR_LEN)) {
-                       if (node == *spec_scan_head) {
-                               *spec_scan_head = node->next;
-                       }
-                       else {
-                               prev->next = node->next;
-                       }
-
-                       WL_TRACE(("%s : Del node : %s\n", __FUNCTION__, node->bss_info->SSID));
-                       kfree(node);
-                       break;
-               }
-
-               prev = node;
-               node = node->next;
-       }
-
-       memset(addr, 0, ETHER_ADDR_LEN);
-       MUTEX_UNLOCK_WL_SCAN_SET();
-       return 0;
-
-}
-
-#endif 
-
-
-static int
-wl_iw_set_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int error;
-       WL_TRACE(("\n:%s dev:%s: SIOCSIWSCAN : SCAN\n", __FUNCTION__, dev->name));
-
-
-#if defined(CSCAN)
-               WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
-               return -EINVAL;
-#endif 
-
-#if defined(SOFTAP)
-       
-       if (ap_cfg_running) {
-               WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
-               return 0;
-       }
-#endif 
-
-       
-       if (g_onoff == G_WLAN_SET_OFF)
-               return 0;
-
-       
-       memset(&g_specific_ssid, 0, sizeof(g_specific_ssid));
-#ifndef WL_IW_USE_ISCAN
-       
-       g_scan_specified_ssid = 0;
-#endif 
-
-#if WIRELESS_EXT > 17
-       
-       if (wrqu->data.length == sizeof(struct iw_scan_req)) {
-               if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
-                       struct iw_scan_req *req = (struct iw_scan_req *)extra;
-                       if (g_first_broadcast_scan != BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-                               
-                               WL_TRACE(("%s Ignoring SC %s first BC is not done = %d\n", \
-                                               __FUNCTION__, req->essid, \
-                                               g_first_broadcast_scan));
-                               return -EBUSY;
-                       }
-                       if (g_scan_specified_ssid) {
-                               WL_TRACE(("%s Specific SCAN is not done ignore scan for = %s \n", \
-                                       __FUNCTION__, req->essid));
-                               
-                               return -EBUSY;
-                       }
-                       else {
-                               g_specific_ssid.SSID_len = MIN(sizeof(g_specific_ssid.SSID), \
-                                                                               req->essid_len);
-                               memcpy(g_specific_ssid.SSID, req->essid, g_specific_ssid.SSID_len);
-                               g_specific_ssid.SSID_len = htod32(g_specific_ssid.SSID_len);
-                               g_scan_specified_ssid = 1;
-                               WL_TRACE(("### Specific scan ssid=%s len=%d\n", \
-                                               g_specific_ssid.SSID, g_specific_ssid.SSID_len));
-                       }
-               }
-       }
-#endif 
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_SCAN, &g_specific_ssid, sizeof(g_specific_ssid)))) {
-               WL_TRACE(("#### Set SCAN for %s failed with %d\n", g_specific_ssid.SSID, error));
-               
-               g_scan_specified_ssid = 0;
-               return -EBUSY;
-       }
-
-       return 0;
-}
-
-#ifdef WL_IW_USE_ISCAN
-int
-wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag)
-{
-       wlc_ssid_t ssid;
-       iscan_info_t *iscan = g_iscan;
-
-#if !defined(CSCAN)
-       
-       if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_IDLE) {
-               g_first_broadcast_scan = BROADCAST_SCAN_FIRST_STARTED;
-               WL_TRACE(("%s: First Brodcast scan was forced\n", __FUNCTION__));
-       }
-       else if (g_first_broadcast_scan == BROADCAST_SCAN_FIRST_STARTED) {
-               WL_TRACE(("%s: ignore ISCAN request first BS is not done yet\n", __FUNCTION__));
-               return 0;
-       }
-#endif 
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-       if (flag)
-               rtnl_lock();
-#endif
-
-       dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &iscan->scan_flag, sizeof(iscan->scan_flag));
-       wl_iw_set_event_mask(dev);
-
-       WL_TRACE(("+++: Set Broadcast ISCAN\n"));
-       
-       memset(&ssid, 0, sizeof(ssid));
-
-       iscan->list_cur = iscan->list_hdr;
-       iscan->iscan_state = ISCAN_STATE_SCANING;
-
-       memset(&iscan->iscan_ex_params_p->params, 0, iscan->iscan_ex_param_size);
-       wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, &ssid);
-       wl_iw_iscan(iscan, &ssid, WL_SCAN_ACTION_START);
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-       if (flag)
-               rtnl_unlock();
-#endif
-
-       mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
-
-       iscan->timer_on = 1;
-
-       return 0;
-}
-static int
-wl_iw_iscan_set_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       wlc_ssid_t ssid;
-       iscan_info_t *iscan = g_iscan;
-
-       WL_TRACE(("%s: SIOCSIWSCAN : ISCAN\n", dev->name));
-
-#if defined(CSCAN)
-               WL_ERROR(("%s: Scan from SIOCGIWSCAN not supported\n", __FUNCTION__));
-               return -EINVAL;
-#endif 
-
-       
-#if defined(SOFTAP)
-       if (ap_cfg_running) {
-               WL_TRACE(("\n>%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
-               return 0;
-       }
-#endif
-       
-       if (g_onoff == G_WLAN_SET_OFF) {
-               WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
-               return 0;
-       }
-
-       
-       if ((!iscan) || (iscan->sysioc_pid < 0)) {
-               WL_TRACE(("%s use backup if iscan thread is not successful\n", \
-                        __FUNCTION__));
-               return wl_iw_set_scan(dev, info, wrqu, extra);
-       }
-
-       if (g_scan_specified_ssid) {
-               WL_TRACE(("%s Specific SCAN already running ignoring BC scan\n", \
-                               __FUNCTION__));
-               return EBUSY;
-       }
-
-       
-       memset(&ssid, 0, sizeof(ssid));
-
-#if WIRELESS_EXT > 17
-       
-       if (wrqu->data.length == sizeof(struct iw_scan_req)) {
-               if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
-                       int as = 0;
-                       struct iw_scan_req *req = (struct iw_scan_req *)extra;
-#if !defined(CSCAN)
-                       if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_CONSUMED) {
-                               
-                               WL_TRACE(("%s First ISCAN in progress : ignoring SC = %s\n", \
-                                        __FUNCTION__, req->essid));
-                               return -EBUSY;
-                       }
-#endif 
-                       ssid.SSID_len = MIN(sizeof(ssid.SSID), req->essid_len);
-                       memcpy(ssid.SSID, req->essid, ssid.SSID_len);
-                       ssid.SSID_len = htod32(ssid.SSID_len);
-                       dev_wlc_ioctl(dev, WLC_SET_PASSIVE_SCAN, &as, sizeof(as));
-                       wl_iw_set_event_mask(dev);
-                       return wl_iw_set_scan(dev, info, wrqu, extra);
-               }
-               else {
-                       g_scan_specified_ssid = 0;
-
-                       if (iscan->iscan_state == ISCAN_STATE_SCANING) {
-                               WL_TRACE(("%s ISCAN already in progress \n", __FUNCTION__));
-                               return 0;
-                       }
-               }
-       }
-#endif 
-
-       wl_iw_iscan_set_scan_broadcast_prep(dev, 0);
-
-       return 0;
-}
-#endif 
-
-#if WIRELESS_EXT > 17
-static bool
-ie_is_wpa_ie(uint8 **wpaie, uint8 **tlvs, int *tlvs_len)
-{
-
-
-       uint8 *ie = *wpaie;
-
-       
-       if ((ie[1] >= 6) &&
-               !bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x01"), 4)) {
-               return TRUE;
-       }
-
-       
-       ie += ie[1] + 2;
-       
-       *tlvs_len -= (int)(ie - *tlvs);
-       
-       *tlvs = ie;
-       return FALSE;
-}
-
-static bool
-ie_is_wps_ie(uint8 **wpsie, uint8 **tlvs, int *tlvs_len)
-{
-
-
-       uint8 *ie = *wpsie;
-
-       
-       if ((ie[1] >= 4) &&
-               !bcmp((const void *)&ie[2], (const void *)(WPA_OUI "\x04"), 4)) {
-               return TRUE;
-       }
-
-       
-       ie += ie[1] + 2;
-       
-       *tlvs_len -= (int)(ie - *tlvs);
-       
-       *tlvs = ie;
-       return FALSE;
-}
-#endif 
-
-static inline int _wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data,
-       size_t len, int uppercase)
-{
-       size_t i;
-       char *pos = buf, *end = buf + buf_size;
-       int ret;
-       if (buf_size == 0)
-               return 0;
-       for (i = 0; i < len; i++) {
-               ret = snprintf(pos, end - pos, uppercase ? "%02X" : "%02x",
-                       data[i]);
-               if (ret < 0 || ret >= end - pos) {
-                       end[-1] = '\0';
-                       return pos - buf;
-               }
-               pos += ret;
-       }
-       end[-1] = '\0';
-       return pos - buf;
-}
-
-
-int wpa_snprintf_hex(char *buf, size_t buf_size, const u8 *data, size_t len)
-{
-       return _wpa_snprintf_hex(buf, buf_size, data, len, 0);
-}
-
-static int
-wl_iw_handle_scanresults_ies(char **event_p, char *end,
-       struct iw_request_info *info, wl_bss_info_t *bi)
-{
-#if WIRELESS_EXT > 17
-       struct iw_event iwe;
-       char *event;
-       char *buf;
-       int custom_event_len;
-
-       event = *event_p;
-       if (bi->ie_length) {
-               
-               bcm_tlv_t *ie;
-               uint8 *ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
-               int ptr_len = bi->ie_length;
-
-#ifdef BCMWPA2
-               if ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_RSN_ID))) {
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = ie->len + 2;
-                       event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
-               }
-               ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
-#endif 
-
-               while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WPA_ID))) {
-                       
-                       if (ie_is_wps_ie(((uint8 **)&ie), &ptr, &ptr_len)) {
-                               iwe.cmd = IWEVGENIE;
-                               iwe.u.data.length = ie->len + 2;
-                               event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
-                               break;
-                       }
-               }
-
-               ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
-               ptr_len = bi->ie_length;
-               while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WPA_ID))) {
-                       if (ie_is_wpa_ie(((uint8 **)&ie), &ptr, &ptr_len)) {
-                               iwe.cmd = IWEVGENIE;
-                               iwe.u.data.length = ie->len + 2;
-                               event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
-                               break;
-                       }
-               }
-
-               ptr = ((uint8 *)bi) + sizeof(wl_bss_info_t);
-               ptr_len = bi->ie_length;
-
-               while ((ie = bcm_parse_tlvs(ptr, ptr_len, DOT11_MNG_WAPI_ID))) {
-                       WL_TRACE(("%s: found a WAPI IE...\n", __FUNCTION__));
-#ifdef WAPI_IE_USE_GENIE
-                       iwe.cmd = IWEVGENIE;
-                       iwe.u.data.length = ie->len + 2;
-                       event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)ie);
-#else 
-                       iwe.cmd = IWEVCUSTOM;
-                       custom_event_len = strlen("wapi_ie=") + 2*(ie->len + 2);
-                       iwe.u.data.length = custom_event_len;
-
-                       buf = kmalloc(custom_event_len+1, GFP_KERNEL);
-                       if (buf == NULL)
-                       {
-                               WL_ERROR(("malloc(%d) returned NULL...\n", custom_event_len));
-                               break;
-                       }
-
-                       memcpy(buf, "wapi_ie=", 8);
-                       wpa_snprintf_hex(buf + 8, 2+1, &(ie->id), 1);
-                       wpa_snprintf_hex(buf + 10, 2+1, &(ie->len), 1);
-                       wpa_snprintf_hex(buf + 12, 2*ie->len+1, ie->data, ie->len);
-                       event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, buf);
-#endif 
-                       break;
-               }
-       *event_p = event;
-       }
-#endif 
-
-       return 0;
-}
-
-static uint
-wl_iw_get_scan_prep(
-       wl_scan_results_t *list,
-       struct iw_request_info *info,
-       char *extra,
-       short max_size)
-{
-       int  i, j;
-       struct iw_event  iwe;
-       wl_bss_info_t *bi = NULL;
-       char *event = extra, *end = extra + max_size - WE_ADD_EVENT_FIX, *value;
-       int     ret = 0;
-
-       ASSERT(list);
-
-       
-
-       for (i = 0; i < list->count && i < IW_MAX_AP; i++)
-       {
-               if (list->version != WL_BSS_INFO_VERSION) {
-                       WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
-                               __FUNCTION__, list->version));
-                       return ret;
-                }
-
-               bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
-
-               WL_TRACE(("%s : %s\n", __FUNCTION__, bi->SSID));
-
-               
-               iwe.cmd = SIOCGIWAP;
-               iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-               memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
-               event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
-               
-               iwe.u.data.length = dtoh32(bi->SSID_len);
-               iwe.cmd = SIOCGIWESSID;
-               iwe.u.data.flags = 1;
-               event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
-
-               
-               if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
-                       iwe.cmd = SIOCGIWMODE;
-                       if (dtoh16(bi->capability) & DOT11_CAP_ESS)
-                               iwe.u.mode = IW_MODE_INFRA;
-                       else
-                               iwe.u.mode = IW_MODE_ADHOC;
-                       event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
-               }
-
-               
-               iwe.cmd = SIOCGIWFREQ;
-               iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
-                       CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
-                       WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
-               iwe.u.freq.e = 6;
-               event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
-
-               
-               iwe.cmd = IWEVQUAL;
-               iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
-               iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
-               iwe.u.qual.noise = 0x100 + bi->phy_noise;
-               event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
-
-               
-                wl_iw_handle_scanresults_ies(&event, end, info, bi);
-
-               
-               iwe.cmd = SIOCGIWENCODE;
-               if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
-                       iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-               else
-                       iwe.u.data.flags = IW_ENCODE_DISABLED;
-               iwe.u.data.length = 0;
-               event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
-
-               
-               if (bi->rateset.count) {
-                       if (((event -extra) + IW_EV_LCP_LEN) <= (uintptr)end) {
-                               value = event + IW_EV_LCP_LEN;
-                               iwe.cmd = SIOCGIWRATE;
-                               
-                               iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
-                               for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
-                                       iwe.u.bitrate.value =
-                                               (bi->rateset.rates[j] & 0x7f) * 500000;
-                                       value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
-                                               IW_EV_PARAM_LEN);
-                               }
-                               event = value;
-                       }
-               }
-       } 
-
-       if ((ret = (event - extra)) < 0) {
-               WL_ERROR(("==> Wrong size\n"));
-               ret = 0;
-       }
-       WL_TRACE(("%s: size=%d bytes prepared \n", __FUNCTION__, (unsigned int)(event - extra)));
-       return (uint)ret;
-}
-
-static int
-wl_iw_get_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       channel_info_t ci;
-       wl_scan_results_t *list_merge;
-       wl_scan_results_t *list = (wl_scan_results_t *) g_scan;
-       int error;
-       uint buflen_from_user = dwrq->length;
-       uint len =  G_SCAN_RESULTS;
-       __u16 len_ret = 0;
-#if  !defined(CSCAN)
-       __u16 merged_len = 0;
-#endif
-#if defined(WL_IW_USE_ISCAN)
-       iscan_info_t *iscan = g_iscan;
-       iscan_buf_t * p_buf;
-#if  !defined(CSCAN)
-       uint32 counter = 0;
-#endif 
-#endif 
-
-       WL_TRACE(("%s: buflen_from_user %d: \n", dev->name, buflen_from_user));
-
-       if (!extra) {
-               WL_TRACE(("%s: wl_iw_get_scan return -EINVAL\n", dev->name));
-               return -EINVAL;
-       }
-
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci))))
-               return error;
-       ci.scan_channel = dtoh32(ci.scan_channel);
-       if (ci.scan_channel)
-               return -EAGAIN;
-
-#if  !defined(CSCAN)
-       if (g_ss_cache_ctrl.m_timer_expired) {
-               wl_iw_free_ss_cache();
-               g_ss_cache_ctrl.m_timer_expired ^= 1;
-       }
-       if ((!g_scan_specified_ssid && g_ss_cache_ctrl.m_prev_scan_mode) ||
-               g_ss_cache_ctrl.m_cons_br_scan_cnt > 4) {
-               g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-               
-               wl_iw_reset_ss_cache();
-       }
-       g_ss_cache_ctrl.m_prev_scan_mode = g_scan_specified_ssid;
-       if (g_scan_specified_ssid) {
-               g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-       }
-       else {
-               g_ss_cache_ctrl.m_cons_br_scan_cnt++;
-       }
-#endif 
-
-
-       
-       if (g_scan_specified_ssid) {
-               
-               list = kmalloc(len, GFP_KERNEL);
-               if (!list) {
-                       WL_TRACE(("%s: wl_iw_get_scan return -ENOMEM\n", dev->name));
-                       g_scan_specified_ssid = 0;
-                       return -ENOMEM;
-               }
-       }
-
-       memset(list, 0, len);
-       list->buflen = htod32(len);
-       if ((error = dev_wlc_ioctl(dev, WLC_SCAN_RESULTS, list, len))) {
-               WL_TRACE(("%s: %s : Scan_results ERROR %d\n", dev->name, __FUNCTION__, len));
-               dwrq->length = len;
-               if (g_scan_specified_ssid)
-                       kfree(list);
-               return 0;
-       }
-       list->buflen = dtoh32(list->buflen);
-       list->version = dtoh32(list->version);
-       list->count = dtoh32(list->count);
-
-       
-       if (list->version != WL_BSS_INFO_VERSION) {
-               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
-                        __FUNCTION__, list->version));
-               if (g_scan_specified_ssid) {
-                       g_scan_specified_ssid = 0;
-                       kfree(list);
-               }
-               return -EINVAL;
-       }
-
-#if  !defined(CSCAN)
-       if (g_scan_specified_ssid) {
-               
-               wl_iw_add_bss_to_ss_cache(list);
-               kfree(list);
-       }
-#endif
-
-#if  !defined(CSCAN)
-       MUTEX_LOCK_WL_SCAN_SET();
-#if defined(WL_IW_USE_ISCAN)
-       if (g_scan_specified_ssid)
-               WL_TRACE(("%s: Specified scan APs from scan=%d\n", __FUNCTION__, list->count));
-       p_buf = iscan->list_hdr;
-       
-       while (p_buf != iscan->list_cur) {
-               list_merge = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
-               WL_TRACE(("%s: Bcast APs list=%d\n", __FUNCTION__, list_merge->count));
-               counter += list_merge->count;
-               if (list_merge->count > 0)
-                       len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info,
-                           extra+len_ret, buflen_from_user -len_ret);
-               p_buf = p_buf->next;
-       }
-       WL_TRACE(("%s merged with total Bcast APs=%d\n", __FUNCTION__, counter));
-#else
-       list_merge = (wl_scan_results_t *) g_scan;
-       len_ret = (__u16) wl_iw_get_scan_prep(list_merge, info, extra, buflen_from_user);
-#endif 
-       MUTEX_UNLOCK_WL_SCAN_SET();
-       if (g_ss_cache_ctrl.m_link_down) {
-               
-               wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
-       }
-       
-       wl_iw_merge_scan_cache(info, extra+len_ret, buflen_from_user-len_ret, &merged_len);
-       len_ret += merged_len;
-       wl_iw_run_ss_cache_timer(0);
-       wl_iw_run_ss_cache_timer(1);
-#else  
-
-       
-       if (g_scan_specified_ssid) {
-               WL_TRACE(("%s: Specified scan APs in the list =%d\n", __FUNCTION__, list->count));
-               len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
-               kfree(list);
-
-#if defined(WL_IW_USE_ISCAN)
-               p_buf = iscan->list_hdr;
-               
-               while (p_buf != iscan->list_cur) {
-                       list_merge = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
-                       WL_TRACE(("%s: Bcast APs list=%d\n", __FUNCTION__, list_merge->count));
-                       if (list_merge->count > 0)
-                               len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info,
-                                   extra+len_ret, buflen_from_user -len_ret);
-                       p_buf = p_buf->next;
-               }
-#else
-               list_merge = (wl_scan_results_t *) g_scan;
-               WL_TRACE(("%s: Bcast APs list=%d\n", __FUNCTION__, list_merge->count));
-               if (list_merge->count > 0)
-                       len_ret += (__u16) wl_iw_get_scan_prep(list_merge, info, extra+len_ret,
-                               buflen_from_user -len_ret);
-#endif 
-       }
-       else {
-               list = (wl_scan_results_t *) g_scan;
-               len_ret = (__u16) wl_iw_get_scan_prep(list, info, extra, buflen_from_user);
-       }
-#endif 
-
-#if defined(WL_IW_USE_ISCAN)
-       
-       g_scan_specified_ssid = 0;
-#endif 
-       
-       if ((len_ret + WE_ADD_EVENT_FIX) < buflen_from_user)
-               len = len_ret;
-
-       dwrq->length = len;
-       dwrq->flags = 0;        
-
-       WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, list->count));
-       return 0;
-}
-
-#if defined(WL_IW_USE_ISCAN)
-static int
-wl_iw_iscan_get_scan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_scan_results_t *list;
-       struct iw_event iwe;
-       wl_bss_info_t *bi = NULL;
-       int ii, j;
-       int apcnt;
-       char *event = extra, *end = extra + dwrq->length, *value;
-       iscan_info_t *iscan = g_iscan;
-       iscan_buf_t * p_buf;
-       uint32  counter = 0;
-#if !defined(CSCAN)
-       __u16 merged_len = 0;
-       uint buflen_from_user = dwrq->length;
-#endif
-
-       WL_TRACE(("%s %s buflen_from_user %d:\n", dev->name, __FUNCTION__, dwrq->length));
-
-#if defined(SOFTAP)
-       if (ap_cfg_running) {
-               WL_TRACE(("%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
-               return -EINVAL;
-       }
-#endif
-
-       if (!extra) {
-               WL_TRACE(("%s: INVALID SIOCGIWSCAN GET bad parameter\n", dev->name));
-               return -EINVAL;
-       }
-
-#if !defined(CSCAN)
-       if (g_first_broadcast_scan < BROADCAST_SCAN_FIRST_RESULT_READY) {
-               WL_TRACE(("%s %s: first ISCAN results are NOT ready yet \n", \
-                        dev->name, __FUNCTION__));
-               return -EAGAIN;
-       }
-#endif 
-       
-       if ((!iscan) || (iscan->sysioc_pid < 0)) {
-               WL_TRACE(("%ssysioc_pid\n", __FUNCTION__));
-               return wl_iw_get_scan(dev, info, dwrq, extra);
-       }
-
-#if !defined(CSCAN)
-       if (g_ss_cache_ctrl.m_timer_expired) {
-               wl_iw_free_ss_cache();
-               g_ss_cache_ctrl.m_timer_expired ^= 1;
-       }
-       if (g_scan_specified_ssid) {
-               return wl_iw_get_scan(dev, info, dwrq, extra);
-       }
-       else {
-               if (g_ss_cache_ctrl.m_link_down) {
-                       
-                       wl_iw_delete_bss_from_ss_cache(g_ss_cache_ctrl.m_active_bssid);
-               }
-               if (g_ss_cache_ctrl.m_prev_scan_mode || g_ss_cache_ctrl.m_cons_br_scan_cnt > 4) {
-                       g_ss_cache_ctrl.m_cons_br_scan_cnt = 0;
-                       
-                       wl_iw_reset_ss_cache();
-               }
-               g_ss_cache_ctrl.m_prev_scan_mode = g_scan_specified_ssid;
-               g_ss_cache_ctrl.m_cons_br_scan_cnt++;
-       }
-#endif 
-
-       WL_TRACE(("%s: SIOCGIWSCAN GET broadcast results\n", dev->name));
-       apcnt = 0;
-       p_buf = iscan->list_hdr;
-       
-       while (p_buf != iscan->list_cur) {
-           list = &((wl_iscan_results_t*)p_buf->iscan_buf)->results;
-
-       counter += list->count;
-
-           if (list->version != WL_BSS_INFO_VERSION) {
-               WL_ERROR(("%s : list->version %d != WL_BSS_INFO_VERSION\n", \
-                        __FUNCTION__, list->version));
-               return -EINVAL;
-           }
-
-           bi = NULL;
-           for (ii = 0; ii < list->count && apcnt < IW_MAX_AP; apcnt++, ii++) {
-               bi = bi ? (wl_bss_info_t *)((uintptr)bi + dtoh32(bi->length)) : list->bss_info;
-               ASSERT(((uintptr)bi + dtoh32(bi->length)) <= ((uintptr)list +
-                       WLC_IW_ISCAN_MAXLEN));
-
-               
-               if (event + ETHER_ADDR_LEN + bi->SSID_len + IW_EV_UINT_LEN + IW_EV_FREQ_LEN +
-                       IW_EV_QUAL_LEN >= end)
-                       return -E2BIG;
-               
-               iwe.cmd = SIOCGIWAP;
-               iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-               memcpy(iwe.u.ap_addr.sa_data, &bi->BSSID, ETHER_ADDR_LEN);
-               event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_ADDR_LEN);
-
-               
-               iwe.u.data.length = dtoh32(bi->SSID_len);
-               iwe.cmd = SIOCGIWESSID;
-               iwe.u.data.flags = 1;
-               event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, bi->SSID);
-
-               
-               if (dtoh16(bi->capability) & (DOT11_CAP_ESS | DOT11_CAP_IBSS)) {
-                       iwe.cmd = SIOCGIWMODE;
-                       if (dtoh16(bi->capability) & DOT11_CAP_ESS)
-                               iwe.u.mode = IW_MODE_INFRA;
-                       else
-                               iwe.u.mode = IW_MODE_ADHOC;
-                       event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_UINT_LEN);
-               }
-
-               
-               iwe.cmd = SIOCGIWFREQ;
-               iwe.u.freq.m = wf_channel2mhz(CHSPEC_CHANNEL(bi->chanspec),
-                       CHSPEC_CHANNEL(bi->chanspec) <= CH_MAX_2G_CHANNEL ?
-                       WF_CHAN_FACTOR_2_4_G : WF_CHAN_FACTOR_5_G);
-               iwe.u.freq.e = 6;
-               event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_FREQ_LEN);
-
-               
-               iwe.cmd = IWEVQUAL;
-               iwe.u.qual.qual = rssi_to_qual(dtoh16(bi->RSSI));
-               iwe.u.qual.level = 0x100 + dtoh16(bi->RSSI);
-               iwe.u.qual.noise = 0x100 + bi->phy_noise;
-               event = IWE_STREAM_ADD_EVENT(info, event, end, &iwe, IW_EV_QUAL_LEN);
-
-               
-               wl_iw_handle_scanresults_ies(&event, end, info, bi);
-
-               
-               iwe.cmd = SIOCGIWENCODE;
-               if (dtoh16(bi->capability) & DOT11_CAP_PRIVACY)
-                       iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-               else
-                       iwe.u.data.flags = IW_ENCODE_DISABLED;
-               iwe.u.data.length = 0;
-               event = IWE_STREAM_ADD_POINT(info, event, end, &iwe, (char *)event);
-
-               
-               if (bi->rateset.count) {
-                       if (event + IW_MAX_BITRATES*IW_EV_PARAM_LEN >= end)
-                               return -E2BIG;
-
-                       value = event + IW_EV_LCP_LEN;
-                       iwe.cmd = SIOCGIWRATE;
-                       
-                       iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
-                       for (j = 0; j < bi->rateset.count && j < IW_MAX_BITRATES; j++) {
-                               iwe.u.bitrate.value = (bi->rateset.rates[j] & 0x7f) * 500000;
-                               value = IWE_STREAM_ADD_VALUE(info, event, value, end, &iwe,
-                                       IW_EV_PARAM_LEN);
-                       }
-                       event = value;
-               }
-           }
-           p_buf = p_buf->next;
-       } 
-
-       dwrq->length = event - extra;
-       dwrq->flags = 0;        
-
-#if !defined(CSCAN)
-       
-       wl_iw_merge_scan_cache(info, event, buflen_from_user - dwrq->length, &merged_len);
-       dwrq->length += merged_len;
-       wl_iw_run_ss_cache_timer(0);
-       wl_iw_run_ss_cache_timer(1);
-       
-       g_first_broadcast_scan = BROADCAST_SCAN_FIRST_RESULT_CONSUMED;
-#endif
-
-       WL_TRACE(("%s return to WE %d bytes APs=%d\n", __FUNCTION__, dwrq->length, counter));
-
-       
-       if (!dwrq->length)
-               return -EAGAIN;
-
-       return 0;
-}
-#endif 
-
-static int
-wl_iw_set_essid(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       int error;
-
-       WL_TRACE(("%s: SIOCSIWESSID\n", dev->name));
-
-
-       
-       memset(&g_ssid, 0, sizeof(g_ssid));
-
-       CHECK_EXTRA_FOR_NULL(extra);
-
-       if (dwrq->length && extra) {
-#if WIRELESS_EXT > 20
-               g_ssid.SSID_len = MIN(sizeof(g_ssid.SSID), dwrq->length);
-#else
-               g_ssid.SSID_len = MIN(sizeof(g_ssid.SSID), dwrq->length-1);
-#endif
-               memcpy(g_ssid.SSID, extra, g_ssid.SSID_len);
-       } else {
-               
-               g_ssid.SSID_len = 0;
-       }
-       g_ssid.SSID_len = htod32(g_ssid.SSID_len);
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_SSID, &g_ssid, sizeof(g_ssid))))
-               return error;
-
-       if (g_ssid.SSID_len) {
-               WL_TRACE(("%s: join SSID=%s\n", __FUNCTION__,  g_ssid.SSID));
-       }
-       return 0;
-}
-
-static int
-wl_iw_get_essid(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wlc_ssid_t ssid;
-       int error;
-
-       WL_TRACE(("%s: SIOCGIWESSID\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_SSID, &ssid, sizeof(ssid)))) {
-               WL_ERROR(("Error getting the SSID\n"));
-               return error;
-       }
-
-       ssid.SSID_len = dtoh32(ssid.SSID_len);
-
-       
-       memcpy(extra, ssid.SSID, ssid.SSID_len);
-
-       dwrq->length = ssid.SSID_len;
-
-       dwrq->flags = 1; 
-
-       return 0;
-}
-
-static int
-wl_iw_set_nick(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
-       WL_TRACE(("%s: SIOCSIWNICKN\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       
-       if (dwrq->length > sizeof(iw->nickname))
-               return -E2BIG;
-
-       memcpy(iw->nickname, extra, dwrq->length);
-       iw->nickname[dwrq->length - 1] = '\0';
-
-       return 0;
-}
-
-static int
-wl_iw_get_nick(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
-       WL_TRACE(("%s: SIOCGIWNICKN\n", dev->name));
-
-       if (!extra)
-               return -EINVAL;
-
-       strcpy(extra, iw->nickname);
-       dwrq->length = strlen(extra) + 1;
-
-       return 0;
-}
-
-static int wl_iw_set_rate(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       wl_rateset_t rateset;
-       int error, rate, i, error_bg, error_a;
-
-       WL_TRACE(("%s: SIOCSIWRATE\n", dev->name));
-
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset))))
-               return error;
-
-       rateset.count = dtoh32(rateset.count);
-
-       if (vwrq->value < 0) {
-               
-               rate = rateset.rates[rateset.count - 1] & 0x7f;
-       } else if (vwrq->value < rateset.count) {
-               
-               rate = rateset.rates[vwrq->value] & 0x7f;
-       } else {
-               
-               rate = vwrq->value / 500000;
-       }
-
-       if (vwrq->fixed) {
-               
-               error_bg = dev_wlc_intvar_set(dev, "bg_rate", rate);
-               error_a = dev_wlc_intvar_set(dev, "a_rate", rate);
-
-               if (error_bg && error_a)
-                       return (error_bg | error_a);
-       } else {
-               
-               
-               error_bg = dev_wlc_intvar_set(dev, "bg_rate", 0);
-               
-               error_a = dev_wlc_intvar_set(dev, "a_rate", 0);
-
-               if (error_bg && error_a)
-                       return (error_bg | error_a);
-
-               
-               for (i = 0; i < rateset.count; i++)
-                       if ((rateset.rates[i] & 0x7f) > rate)
-                               break;
-               rateset.count = htod32(i);
-
-               
-               if ((error = dev_wlc_ioctl(dev, WLC_SET_RATESET, &rateset, sizeof(rateset))))
-                       return error;
-       }
-
-       return 0;
-}
-
-static int wl_iw_get_rate(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, rate;
-
-       WL_TRACE(("%s: SIOCGIWRATE\n", dev->name));
-
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_RATE, &rate, sizeof(rate))))
-               return error;
-       rate = dtoh32(rate);
-       vwrq->value = rate * 500000;
-
-       return 0;
-}
-
-static int
-wl_iw_set_rts(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, rts;
-
-       WL_TRACE(("%s: SIOCSIWRTS\n", dev->name));
-
-       if (vwrq->disabled)
-               rts = DOT11_DEFAULT_RTS_LEN;
-       else if (vwrq->value < 0 || vwrq->value > DOT11_DEFAULT_RTS_LEN)
-               return -EINVAL;
-       else
-               rts = vwrq->value;
-
-       if ((error = dev_wlc_intvar_set(dev, "rtsthresh", rts)))
-               return error;
-
-       return 0;
-}
-
-static int
-wl_iw_get_rts(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, rts;
-
-       WL_TRACE(("%s: SIOCGIWRTS\n", dev->name));
-
-       if ((error = dev_wlc_intvar_get(dev, "rtsthresh", &rts)))
-               return error;
-
-       vwrq->value = rts;
-       vwrq->disabled = (rts >= DOT11_DEFAULT_RTS_LEN);
-       vwrq->fixed = 1;
-
-       return 0;
-}
-
-static int
-wl_iw_set_frag(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, frag;
-
-       WL_TRACE(("%s: SIOCSIWFRAG\n", dev->name));
-
-       if (vwrq->disabled)
-               frag = DOT11_DEFAULT_FRAG_LEN;
-       else if (vwrq->value < 0 || vwrq->value > DOT11_DEFAULT_FRAG_LEN)
-               return -EINVAL;
-       else
-               frag = vwrq->value;
-
-       if ((error = dev_wlc_intvar_set(dev, "fragthresh", frag)))
-               return error;
-
-       return 0;
-}
-
-static int
-wl_iw_get_frag(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, fragthreshold;
-
-       WL_TRACE(("%s: SIOCGIWFRAG\n", dev->name));
-
-       if ((error = dev_wlc_intvar_get(dev, "fragthresh", &fragthreshold)))
-               return error;
-
-       vwrq->value = fragthreshold;
-       vwrq->disabled = (fragthreshold >= DOT11_DEFAULT_FRAG_LEN);
-       vwrq->fixed = 1;
-
-       return 0;
-}
-
-static int
-wl_iw_set_txpow(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, disable;
-       uint16 txpwrmw;
-       WL_TRACE(("%s: SIOCSIWTXPOW\n", dev->name));
-
-       
-       disable = vwrq->disabled ? WL_RADIO_SW_DISABLE : 0;
-       disable += WL_RADIO_SW_DISABLE << 16;
-
-       disable = htod32(disable);
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_RADIO, &disable, sizeof(disable))))
-               return error;
-
-       
-       if (disable & WL_RADIO_SW_DISABLE)
-               return 0;
-
-       
-       if (!(vwrq->flags & IW_TXPOW_MWATT))
-               return -EINVAL;
-
-       
-       if (vwrq->value < 0)
-               return 0;
-
-       if (vwrq->value > 0xffff) txpwrmw = 0xffff;
-       else txpwrmw = (uint16)vwrq->value;
-
-
-       error = dev_wlc_intvar_set(dev, "qtxpower", (int)(bcm_mw_to_qdbm(txpwrmw)));
-       return error;
-}
-
-static int
-wl_iw_get_txpow(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, disable, txpwrdbm;
-       uint8 result;
-
-       WL_TRACE(("%s: SIOCGIWTXPOW\n", dev->name));
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_RADIO, &disable, sizeof(disable))) ||
-           (error = dev_wlc_intvar_get(dev, "qtxpower", &txpwrdbm)))
-               return error;
-
-       disable = dtoh32(disable);
-       result = (uint8)(txpwrdbm & ~WL_TXPWR_OVERRIDE);
-       vwrq->value = (int32)bcm_qdbm_to_mw(result);
-       vwrq->fixed = 0;
-       vwrq->disabled = (disable & (WL_RADIO_SW_DISABLE | WL_RADIO_HW_DISABLE)) ? 1 : 0;
-       vwrq->flags = IW_TXPOW_MWATT;
-
-       return 0;
-}
-
-#if WIRELESS_EXT > 10
-static int
-wl_iw_set_retry(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, lrl, srl;
-
-       WL_TRACE(("%s: SIOCSIWRETRY\n", dev->name));
-
-       
-       if (vwrq->disabled || (vwrq->flags & IW_RETRY_LIFETIME))
-               return -EINVAL;
-
-       
-       if (vwrq->flags & IW_RETRY_LIMIT) {
-
-               
-#if WIRELESS_EXT > 20
-       if ((vwrq->flags & IW_RETRY_LONG) ||(vwrq->flags & IW_RETRY_MAX) ||
-               !((vwrq->flags & IW_RETRY_SHORT) || (vwrq->flags & IW_RETRY_MIN))) {
-#else
-       if ((vwrq->flags & IW_RETRY_MAX) || !(vwrq->flags & IW_RETRY_MIN)) {
-#endif 
-                       lrl = htod32(vwrq->value);
-                       if ((error = dev_wlc_ioctl(dev, WLC_SET_LRL, &lrl, sizeof(lrl))))
-                               return error;
-               }
-
-               
-#if WIRELESS_EXT > 20
-       if ((vwrq->flags & IW_RETRY_SHORT) ||(vwrq->flags & IW_RETRY_MIN) ||
-               !((vwrq->flags & IW_RETRY_LONG) || (vwrq->flags & IW_RETRY_MAX))) {
-#else
-               if ((vwrq->flags & IW_RETRY_MIN) || !(vwrq->flags & IW_RETRY_MAX)) {
-#endif 
-                       srl = htod32(vwrq->value);
-                       if ((error = dev_wlc_ioctl(dev, WLC_SET_SRL, &srl, sizeof(srl))))
-                               return error;
-               }
-       }
-       return 0;
-}
-
-static int
-wl_iw_get_retry(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, lrl, srl;
-
-       WL_TRACE(("%s: SIOCGIWRETRY\n", dev->name));
-
-       vwrq->disabled = 0;      
-
-       
-       if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
-               return -EINVAL;
-
-       
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_LRL, &lrl, sizeof(lrl))) ||
-           (error = dev_wlc_ioctl(dev, WLC_GET_SRL, &srl, sizeof(srl))))
-               return error;
-
-       lrl = dtoh32(lrl);
-       srl = dtoh32(srl);
-
-       
-       if (vwrq->flags & IW_RETRY_MAX) {
-               vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
-               vwrq->value = lrl;
-       } else {
-               vwrq->flags = IW_RETRY_LIMIT;
-               vwrq->value = srl;
-               if (srl != lrl)
-                       vwrq->flags |= IW_RETRY_MIN;
-       }
-
-       return 0;
-}
-#endif 
-
-static int
-wl_iw_set_encode(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_wsec_key_t key;
-       int error, val, wsec;
-
-       WL_TRACE(("%s: SIOCSIWENCODE\n", dev->name));
-
-       memset(&key, 0, sizeof(key));
-
-       if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
-               
-               for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) {
-                       val = htod32(key.index);
-                       if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val))))
-                               return error;
-                       val = dtoh32(val);
-                       if (val)
-                               break;
-               }
-               
-               if (key.index == DOT11_MAX_DEFAULT_KEYS)
-                       key.index = 0;
-       } else {
-               key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-               if (key.index >= DOT11_MAX_DEFAULT_KEYS)
-                       return -EINVAL;
-       }
-
-       
-       if (!extra || !dwrq->length || (dwrq->flags & IW_ENCODE_NOKEY)) {
-               
-               val = htod32(key.index);
-               if ((error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY, &val, sizeof(val))))
-                       return error;
-       } else {
-               key.len = dwrq->length;
-
-               if (dwrq->length > sizeof(key.data))
-                       return -EINVAL;
-
-               memcpy(key.data, extra, dwrq->length);
-
-               key.flags = WL_PRIMARY_KEY;
-               switch (key.len) {
-               case WEP1_KEY_SIZE:
-                       key.algo = CRYPTO_ALGO_WEP1;
-                       break;
-               case WEP128_KEY_SIZE:
-                       key.algo = CRYPTO_ALGO_WEP128;
-                       break;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
-               case TKIP_KEY_SIZE:
-                       key.algo = CRYPTO_ALGO_TKIP;
-                       break;
-#endif
-               case AES_KEY_SIZE:
-                       key.algo = CRYPTO_ALGO_AES_CCM;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-
-               
-               swap_key_from_BE(&key);
-               if ((error = dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key))))
-                       return error;
-       }
-
-       
-       val = (dwrq->flags & IW_ENCODE_DISABLED) ? 0 : WEP_ENABLED;
-
-       if ((error = dev_wlc_intvar_get(dev, "wsec", &wsec)))
-               return error;
-
-       wsec  &= ~(WEP_ENABLED);
-       wsec |= val;
-
-       if ((error = dev_wlc_intvar_set(dev, "wsec", wsec)))
-               return error;
-
-       
-       val = (dwrq->flags & IW_ENCODE_RESTRICTED) ? 1 : 0;
-       val = htod32(val);
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_AUTH, &val, sizeof(val))))
-               return error;
-
-       return 0;
-}
-
-static int
-wl_iw_get_encode(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_wsec_key_t key;
-       int error, val, wsec, auth;
-
-       WL_TRACE(("%s: SIOCGIWENCODE\n", dev->name));
-
-       
-       bzero(&key, sizeof(wl_wsec_key_t));
-
-       if ((dwrq->flags & IW_ENCODE_INDEX) == 0) {
-               
-               for (key.index = 0; key.index < DOT11_MAX_DEFAULT_KEYS; key.index++) {
-                       val = key.index;
-                       if ((error = dev_wlc_ioctl(dev, WLC_GET_KEY_PRIMARY, &val, sizeof(val))))
-                               return error;
-                       val = dtoh32(val);
-                       if (val)
-                               break;
-               }
-       } else
-               key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-
-       if (key.index >= DOT11_MAX_DEFAULT_KEYS)
-               key.index = 0;
-
-       
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_WSEC, &wsec, sizeof(wsec))) ||
-           (error = dev_wlc_ioctl(dev, WLC_GET_AUTH, &auth, sizeof(auth))))
-               return error;
-
-       swap_key_to_BE(&key);
-
-       wsec = dtoh32(wsec);
-       auth = dtoh32(auth);
-       
-       dwrq->length = MIN(DOT11_MAX_KEY_SIZE, key.len);
-
-       
-       dwrq->flags = key.index + 1;
-       if (!(wsec & (WEP_ENABLED | TKIP_ENABLED | AES_ENABLED))) {
-               
-               dwrq->flags |= IW_ENCODE_DISABLED;
-       }
-       if (auth) {
-               
-               dwrq->flags |= IW_ENCODE_RESTRICTED;
-       }
-
-       
-       if (dwrq->length && extra)
-               memcpy(extra, key.data, dwrq->length);
-
-       return 0;
-}
-
-static int
-wl_iw_set_power(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, pm;
-
-       WL_TRACE(("%s: SIOCSIWPOWER\n", dev->name));
-
-       pm = vwrq->disabled ? PM_OFF : PM_MAX;
-
-       pm = htod32(pm);
-       if ((error = dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm))))
-               return error;
-
-       return 0;
-}
-
-static int
-wl_iw_get_power(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error, pm;
-
-       WL_TRACE(("%s: SIOCGIWPOWER\n", dev->name));
-
-       if ((error = dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))))
-               return error;
-
-       pm = dtoh32(pm);
-       vwrq->disabled = pm ? 0 : 1;
-       vwrq->flags = IW_POWER_ALL_R;
-
-       return 0;
-}
-
-#if WIRELESS_EXT > 17
-static int
-wl_iw_set_wpaie(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *iwp,
-       char *extra
-)
-{
-       uchar buf[WLC_IOCTL_SMLEN] = {0};
-       uchar *p = buf;
-       int wapi_ie_size;
-
-       WL_TRACE(("%s: SIOCSIWGENIE\n", dev->name));
-
-       CHECK_EXTRA_FOR_NULL(extra);
-
-       if (extra[0] == DOT11_MNG_WAPI_ID)
-       {
-               wapi_ie_size = iwp->length;
-               memcpy(p, extra, iwp->length);
-               dev_wlc_bufvar_set(dev, "wapiie", buf, wapi_ie_size);
-       }
-       else
-               dev_wlc_bufvar_set(dev, "wpaie", extra, iwp->length);
-
-       return 0;
-}
-
-static int
-wl_iw_get_wpaie(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *iwp,
-       char *extra
-)
-{
-       WL_TRACE(("%s: SIOCGIWGENIE\n", dev->name));
-       iwp->length = 64;
-       dev_wlc_bufvar_get(dev, "wpaie", extra, iwp->length);
-       return 0;
-}
-
-static int
-wl_iw_set_encodeext(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *extra
-)
-{
-       wl_wsec_key_t key;
-       int error;
-       struct iw_encode_ext *iwe;
-
-       WL_TRACE(("%s: SIOCSIWENCODEEXT\n", dev->name));
-
-       CHECK_EXTRA_FOR_NULL(extra);
-
-       memset(&key, 0, sizeof(key));
-       iwe = (struct iw_encode_ext *)extra;
-
-       
-       if (dwrq->flags & IW_ENCODE_DISABLED) {
-
-       }
-
-       
-       key.index = 0;
-       if (dwrq->flags & IW_ENCODE_INDEX)
-               key.index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
-
-       key.len = iwe->key_len;
-
-       
-       if (!ETHER_ISMULTI(iwe->addr.sa_data))
-               bcopy((void *)&iwe->addr.sa_data, (char *)&key.ea, ETHER_ADDR_LEN);
-
-       
-       if (key.len == 0) {
-               if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-                       WL_WSEC(("Changing the the primary Key to %d\n", key.index));
-                       
-                       key.index = htod32(key.index);
-                       error = dev_wlc_ioctl(dev, WLC_SET_KEY_PRIMARY,
-                               &key.index, sizeof(key.index));
-                       if (error)
-                               return error;
-               }
-               
-               else {
-                       swap_key_from_BE(&key);
-                       dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
-               }
-       }
-       else {
-               if (iwe->key_len > sizeof(key.data))
-                       return -EINVAL;
-
-               WL_WSEC(("Setting the key index %d\n", key.index));
-               if (iwe->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-                       WL_WSEC(("key is a Primary Key\n"));
-                       key.flags = WL_PRIMARY_KEY;
-               }
-
-               bcopy((void *)iwe->key, key.data, iwe->key_len);
-
-               if (iwe->alg == IW_ENCODE_ALG_TKIP) {
-                       uint8 keybuf[8];
-                       bcopy(&key.data[24], keybuf, sizeof(keybuf));
-                       bcopy(&key.data[16], &key.data[24], sizeof(keybuf));
-                       bcopy(keybuf, &key.data[16], sizeof(keybuf));
-               }
-
-               
-               if (iwe->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) {
-                       uchar *ivptr;
-                       ivptr = (uchar *)iwe->rx_seq;
-                       key.rxiv.hi = (ivptr[5] << 24) | (ivptr[4] << 16) |
-                               (ivptr[3] << 8) | ivptr[2];
-                       key.rxiv.lo = (ivptr[1] << 8) | ivptr[0];
-                       key.iv_initialized = TRUE;
-               }
-
-               switch (iwe->alg) {
-                       case IW_ENCODE_ALG_NONE:
-                               key.algo = CRYPTO_ALGO_OFF;
-                               break;
-                       case IW_ENCODE_ALG_WEP:
-                               if (iwe->key_len == WEP1_KEY_SIZE)
-                                       key.algo = CRYPTO_ALGO_WEP1;
-                               else
-                                       key.algo = CRYPTO_ALGO_WEP128;
-                               break;
-                       case IW_ENCODE_ALG_TKIP:
-                               key.algo = CRYPTO_ALGO_TKIP;
-                               break;
-                       case IW_ENCODE_ALG_CCMP:
-                               key.algo = CRYPTO_ALGO_AES_CCM;
-                               break;
-                       case IW_ENCODE_ALG_SM4:
-                               key.algo = CRYPTO_ALGO_SMS4;
-                               if (iwe->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-                                       key.flags &= ~WL_PRIMARY_KEY;
-                               }
-                               break;
-                       default:
-                               break;
-               }
-               swap_key_from_BE(&key);
-
-               dhd_wait_pend8021x(dev);
-
-               error = dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
-               if (error)
-                       return error;
-       }
-       return 0;
-}
-
-#if WIRELESS_EXT > 17
-#ifdef BCMWPA2
-struct {
-       pmkid_list_t pmkids;
-       pmkid_t foo[MAXPMKID-1];
-} pmkid_list;
-
-static int
-wl_iw_set_pmksa(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       struct iw_pmksa *iwpmksa;
-       uint i;
-       int ret = 0;
-       char eabuf[ETHER_ADDR_STR_LEN];
-
-       WL_WSEC(("%s: SIOCSIWPMKSA\n", dev->name));
-
-       CHECK_EXTRA_FOR_NULL(extra);
-
-       iwpmksa = (struct iw_pmksa *)extra;
-       bzero((char *)eabuf, ETHER_ADDR_STR_LEN);
-
-       if (iwpmksa->cmd == IW_PMKSA_FLUSH) {
-               WL_WSEC(("wl_iw_set_pmksa - IW_PMKSA_FLUSH\n"));
-               bzero((char *)&pmkid_list, sizeof(pmkid_list));
-       }
-
-       else if (iwpmksa->cmd == IW_PMKSA_REMOVE) {
-               {
-                       pmkid_list_t pmkid, *pmkidptr;
-                       uint j;
-                       pmkidptr = &pmkid;
-
-                       bcopy(&iwpmksa->bssid.sa_data[0], &pmkidptr->pmkid[0].BSSID, \
-                               ETHER_ADDR_LEN);
-                       bcopy(&iwpmksa->pmkid[0], &pmkidptr->pmkid[0].PMKID, WPA2_PMKID_LEN);
-
-                       WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_REMOVE - PMKID: %s = ",
-                               bcm_ether_ntoa(&pmkidptr->pmkid[0].BSSID,
-                               eabuf)));
-                       for (j = 0; j < WPA2_PMKID_LEN; j++)
-                               WL_WSEC(("%02x ", pmkidptr->pmkid[0].PMKID[j]));
-                       WL_WSEC(("\n"));
-               }
-
-               for (i = 0; i < pmkid_list.pmkids.npmkid; i++)
-                       if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_list.pmkids.pmkid[i].BSSID,
-                               ETHER_ADDR_LEN))
-                               break;
-
-               if ((pmkid_list.pmkids.npmkid > 0) && (i < pmkid_list.pmkids.npmkid)) {
-                       bzero(&pmkid_list.pmkids.pmkid[i], sizeof(pmkid_t));
-                       for (; i < (pmkid_list.pmkids.npmkid - 1); i++) {
-                               bcopy(&pmkid_list.pmkids.pmkid[i+1].BSSID,
-                                       &pmkid_list.pmkids.pmkid[i].BSSID,
-                                       ETHER_ADDR_LEN);
-                               bcopy(&pmkid_list.pmkids.pmkid[i+1].PMKID,
-                                       &pmkid_list.pmkids.pmkid[i].PMKID,
-                                       WPA2_PMKID_LEN);
-                       }
-                       pmkid_list.pmkids.npmkid--;
-               }
-               else
-                       ret = -EINVAL;
-       }
-
-       else if (iwpmksa->cmd == IW_PMKSA_ADD) {
-               for (i = 0; i < pmkid_list.pmkids.npmkid; i++)
-                       if (!bcmp(&iwpmksa->bssid.sa_data[0], &pmkid_list.pmkids.pmkid[i].BSSID,
-                               ETHER_ADDR_LEN))
-                               break;
-               if (i < MAXPMKID) {
-                       bcopy(&iwpmksa->bssid.sa_data[0],
-                               &pmkid_list.pmkids.pmkid[i].BSSID,
-                               ETHER_ADDR_LEN);
-                       bcopy(&iwpmksa->pmkid[0], &pmkid_list.pmkids.pmkid[i].PMKID,
-                               WPA2_PMKID_LEN);
-                       if (i == pmkid_list.pmkids.npmkid)
-                               pmkid_list.pmkids.npmkid++;
-               }
-               else
-                       ret = -EINVAL;
-               {
-                       uint j;
-                       uint k;
-                       k = pmkid_list.pmkids.npmkid;
-                       WL_WSEC(("wl_iw_set_pmksa,IW_PMKSA_ADD - PMKID: %s = ",
-                               bcm_ether_ntoa(&pmkid_list.pmkids.pmkid[k].BSSID,
-                               eabuf)));
-                       for (j = 0; j < WPA2_PMKID_LEN; j++)
-                               WL_WSEC(("%02x ", pmkid_list.pmkids.pmkid[k].PMKID[j]));
-                       WL_WSEC(("\n"));
-               }
-       }
-       WL_WSEC(("PRINTING pmkid LIST - No of elements %d\n", pmkid_list.pmkids.npmkid));
-       for (i = 0; i < pmkid_list.pmkids.npmkid; i++) {
-               uint j;
-               WL_WSEC(("PMKID[%d]: %s = ", i,
-                       bcm_ether_ntoa(&pmkid_list.pmkids.pmkid[i].BSSID,
-                       eabuf)));
-               for (j = 0; j < WPA2_PMKID_LEN; j++)
-                       WL_WSEC(("%02x ", pmkid_list.pmkids.pmkid[i].PMKID[j]));
-               WL_WSEC(("\n"));
-       }
-       WL_WSEC(("\n"));
-
-       if (!ret)
-               ret = dev_wlc_bufvar_set(dev, "pmkid_info", (char *)&pmkid_list, \
-                       sizeof(pmkid_list));
-       return ret;
-}
-#endif 
-#endif 
-
-static int
-wl_iw_get_encodeext(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       WL_TRACE(("%s: SIOCGIWENCODEEXT\n", dev->name));
-       return 0;
-}
-
-static int
-wl_iw_set_wpaauth(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error = 0;
-       int paramid;
-       int paramval;
-       int val = 0;
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
-       WL_TRACE(("%s: SIOCSIWAUTH\n", dev->name));
-
-#if defined(SOFTAP)
-       if (ap_cfg_running) {
-               WL_TRACE(("%s: Not executed, reason -'SOFTAP is active'\n", __FUNCTION__));
-               return 0;
-       }
-#endif
-
-       paramid = vwrq->flags & IW_AUTH_INDEX;
-       paramval = vwrq->value;
-
-       WL_TRACE(("%s: SIOCSIWAUTH, paramid = 0x%0x, paramval = 0x%0x\n",
-               dev->name, paramid, paramval));
-
-       switch (paramid) {
-       case IW_AUTH_WPA_VERSION:
-               
-               if (paramval & IW_AUTH_WPA_VERSION_DISABLED)
-                       val = WPA_AUTH_DISABLED;
-               else if (paramval & (IW_AUTH_WPA_VERSION_WPA))
-                       val = WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED;
-#ifdef BCMWPA2
-               else if (paramval & IW_AUTH_WPA_VERSION_WPA2)
-                       val = WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED;
-#endif 
-               else if (paramval & IW_AUTH_WAPI_VERSION_1)
-                       val = WPA_AUTH_WAPI;
-               WL_INFORM(("%s: %d: setting wpa_auth to 0x%0x\n", __FUNCTION__, __LINE__, val));
-               if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
-                       return error;
-               break;
-       case IW_AUTH_CIPHER_PAIRWISE:
-       case IW_AUTH_CIPHER_GROUP:
-               
-               
-               if (paramval & (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104))
-                       val =   WEP_ENABLED;
-               if (paramval & IW_AUTH_CIPHER_TKIP)
-                       val = TKIP_ENABLED;
-               if (paramval & IW_AUTH_CIPHER_CCMP)
-                       val = AES_ENABLED;
-               if (paramval & IW_AUTH_CIPHER_SMS4)
-                       val = SMS4_ENABLED;
-
-               if (paramid == IW_AUTH_CIPHER_PAIRWISE) {
-                       iw->pwsec = val;
-                       val |= iw->gwsec;
-               }
-               else {
-                       iw->gwsec = val;
-                       val |= iw->pwsec;
-               }
-
-               if (iw->privacy_invoked && !val) {
-                       WL_WSEC(("%s: %s: 'Privacy invoked' TRUE but clearing wsec, assuming "
-                                "we're a WPS enrollee\n", dev->name, __FUNCTION__));
-                       if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
-                               WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
-                               return error;
-                       }
-               } else if (val) {
-                       if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
-                               WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
-                               return error;
-                       }
-               }
-
-               if ((error = dev_wlc_intvar_set(dev, "wsec", val)))
-                       return error;
-
-               break;
-
-       case IW_AUTH_KEY_MGMT:
-               if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
-                       return error;
-
-               if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
-                       if (paramval & IW_AUTH_KEY_MGMT_PSK)
-                               val = WPA_AUTH_PSK;
-                       else
-                               val = WPA_AUTH_UNSPECIFIED;
-               }
-#ifdef BCMWPA2
-               else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) {
-                       if (paramval & IW_AUTH_KEY_MGMT_PSK)
-                               val = WPA2_AUTH_PSK;
-                       else
-                               val = WPA2_AUTH_UNSPECIFIED;
-               }
-#endif 
-               if (paramval & (IW_AUTH_KEY_MGMT_WAPI_PSK | IW_AUTH_KEY_MGMT_WAPI_CERT))
-                       val = WPA_AUTH_WAPI;
-               WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
-               if ((error = dev_wlc_intvar_set(dev, "wpa_auth", val)))
-                       return error;
-
-               break;
-       case IW_AUTH_TKIP_COUNTERMEASURES:
-               dev_wlc_bufvar_set(dev, "tkip_countermeasures", (char *)&paramval, 1);
-               break;
-
-       case IW_AUTH_80211_AUTH_ALG:
-               
-               WL_INFORM(("Setting the D11auth %d\n", paramval));
-               if (paramval == IW_AUTH_ALG_OPEN_SYSTEM)
-                       val = 0;
-               else if (paramval == IW_AUTH_ALG_SHARED_KEY)
-                       val = 1;
-               else if (paramval == (IW_AUTH_ALG_OPEN_SYSTEM | IW_AUTH_ALG_SHARED_KEY))
-                       val = 2;
-               else
-                       error = 1;
-               if (!error && (error = dev_wlc_intvar_set(dev, "auth", val)))
-                       return error;
-               break;
-
-       case IW_AUTH_WPA_ENABLED:
-               if (paramval == 0) {
-                       iw->pwsec = 0;
-                       iw->gwsec = 0;
-                       if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
-                               return error;
-                       if (val & (TKIP_ENABLED | AES_ENABLED)) {
-                               val &= ~(TKIP_ENABLED | AES_ENABLED);
-                               dev_wlc_intvar_set(dev, "wsec", val);
-                       }
-                       val = 0;
-               WL_INFORM(("%s: %d: setting wpa_auth to %d\n", __FUNCTION__, __LINE__, val));
-                       dev_wlc_intvar_set(dev, "wpa_auth", 0);
-                       return error;
-               }
-
-               
-               break;
-
-       case IW_AUTH_DROP_UNENCRYPTED:
-               dev_wlc_bufvar_set(dev, "wsec_restrict", (char *)&paramval, 1);
-               break;
-
-       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", (char *)&paramval, 1);
-               break;
-
-#if WIRELESS_EXT > 17
-       case IW_AUTH_ROAMING_CONTROL:
-               WL_INFORM(("%s: IW_AUTH_ROAMING_CONTROL\n", __FUNCTION__));
-               
-               break;
-       case IW_AUTH_PRIVACY_INVOKED: {
-               int wsec;
-
-               if (paramval == 0) {
-                       iw->privacy_invoked = FALSE;
-                       if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
-                               WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
-                               return error;
-                       }
-               } else {
-                       iw->privacy_invoked = TRUE;
-                       if ((error = dev_wlc_intvar_get(dev, "wsec", &wsec)))
-                               return error;
-
-                       if (!(IW_WSEC_ENABLED(wsec))) {
-                               
-
-                               if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", TRUE))) {
-                                       WL_WSEC(("Failed to set iovar is_WPS_enrollee\n"));
-                                       return error;
-                               }
-                       } else {
-                               if ((error = dev_wlc_intvar_set(dev, "is_WPS_enrollee", FALSE))) {
-                                       WL_WSEC(("Failed to clear iovar is_WPS_enrollee\n"));
-                                       return error;
-                               }
-                       }
-               }
-               break;
-       }
-#endif 
-       case IW_AUTH_WAPI_ENABLED:
-               if ((error = dev_wlc_intvar_get(dev, "wsec", &val)))
-                       return error;
-               if (paramval) {
-                       val |= SMS4_ENABLED;
-                       if ((error = dev_wlc_intvar_set(dev, "wsec", val))) {
-                               WL_ERROR(("%s: setting wsec to 0x%0x returned error %d\n",
-                                       __FUNCTION__, val, error));
-                               return error;
-                       }
-                       if ((error = dev_wlc_intvar_set(dev, "wpa_auth", WPA_AUTH_WAPI))) {
-                               WL_ERROR(("%s: setting wpa_auth(WPA_AUTH_WAPI) returned %d\n",
-                                       __FUNCTION__, error));
-                               return error;
-                       }
-               }
-
-               break;
-       default:
-               break;
-       }
-       return 0;
-}
-#ifdef BCMWPA2
-#define VAL_PSK(_val) (((_val) & WPA_AUTH_PSK) || ((_val) & WPA2_AUTH_PSK))
-#else
-#define VAL_PSK(_val) (((_val) & WPA_AUTH_PSK))
-#endif 
-
-static int
-wl_iw_get_wpaauth(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_param *vwrq,
-       char *extra
-)
-{
-       int error;
-       int paramid;
-       int paramval = 0;
-       int val;
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-
-       WL_TRACE(("%s: SIOCGIWAUTH\n", dev->name));
-
-       paramid = vwrq->flags & IW_AUTH_INDEX;
-
-       switch (paramid) {
-       case IW_AUTH_WPA_VERSION:
-               
-               if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
-                       return error;
-               if (val & (WPA_AUTH_NONE | WPA_AUTH_DISABLED))
-                       paramval = IW_AUTH_WPA_VERSION_DISABLED;
-               else if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED))
-                       paramval = IW_AUTH_WPA_VERSION_WPA;
-#ifdef BCMWPA2
-               else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED))
-                       paramval = IW_AUTH_WPA_VERSION_WPA2;
-#endif 
-               break;
-       case IW_AUTH_CIPHER_PAIRWISE:
-       case IW_AUTH_CIPHER_GROUP:
-               if (paramid == IW_AUTH_CIPHER_PAIRWISE)
-                       val = iw->pwsec;
-               else
-                       val = iw->gwsec;
-
-               paramval = 0;
-               if (val) {
-                       if (val & WEP_ENABLED)
-                               paramval |= (IW_AUTH_CIPHER_WEP40 | IW_AUTH_CIPHER_WEP104);
-                       if (val & TKIP_ENABLED)
-                               paramval |= (IW_AUTH_CIPHER_TKIP);
-                       if (val & AES_ENABLED)
-                               paramval |= (IW_AUTH_CIPHER_CCMP);
-               }
-               else
-                       paramval = IW_AUTH_CIPHER_NONE;
-               break;
-       case IW_AUTH_KEY_MGMT:
-               
-               if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
-                       return error;
-               if (VAL_PSK(val))
-                       paramval = IW_AUTH_KEY_MGMT_PSK;
-               else
-                       paramval = IW_AUTH_KEY_MGMT_802_1X;
-
-               break;
-       case IW_AUTH_TKIP_COUNTERMEASURES:
-               dev_wlc_bufvar_get(dev, "tkip_countermeasures", (char *)&paramval, 1);
-               break;
-
-       case IW_AUTH_DROP_UNENCRYPTED:
-               dev_wlc_bufvar_get(dev, "wsec_restrict", (char *)&paramval, 1);
-               break;
-
-       case IW_AUTH_RX_UNENCRYPTED_EAPOL:
-               dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", (char *)&paramval, 1);
-               break;
-
-       case IW_AUTH_80211_AUTH_ALG:
-               
-               if ((error = dev_wlc_intvar_get(dev, "auth", &val)))
-                       return error;
-               if (!val)
-                       paramval = IW_AUTH_ALG_OPEN_SYSTEM;
-               else
-                       paramval = IW_AUTH_ALG_SHARED_KEY;
-               break;
-       case IW_AUTH_WPA_ENABLED:
-               if ((error = dev_wlc_intvar_get(dev, "wpa_auth", &val)))
-                       return error;
-               if (val)
-                       paramval = TRUE;
-               else
-                       paramval = FALSE;
-               break;
-#if WIRELESS_EXT > 17
-       case IW_AUTH_ROAMING_CONTROL:
-               WL_ERROR(("%s: IW_AUTH_ROAMING_CONTROL\n", __FUNCTION__));
-               
-               break;
-       case IW_AUTH_PRIVACY_INVOKED:
-               paramval = iw->privacy_invoked;
-               break;
-
-#endif 
-       }
-       vwrq->value = paramval;
-       return 0;
-}
-#endif 
-
-
-#ifdef SOFTAP
-
-static int ap_macmode = MACLIST_MODE_DISABLED;
-static struct mflist ap_black_list;
-static int
-wl_iw_parse_wep(char *keystr, wl_wsec_key_t *key)
-{
-       char hex[] = "XX";
-       unsigned char *data = key->data;
-
-       switch (strlen(keystr)) {
-       case 5:
-       case 13:
-       case 16:
-               key->len = strlen(keystr);
-               memcpy(data, keystr, key->len + 1);
-               break;
-       case 12:
-       case 28:
-       case 34:
-       case 66:
-               
-               if (!strnicmp(keystr, "0x", 2))
-                       keystr += 2;
-               else
-                       return -1;
-               
-       case 10:
-       case 26:
-       case 32:
-       case 64:
-               key->len = strlen(keystr) / 2;
-               while (*keystr) {
-                       strncpy(hex, keystr, 2);
-                       *data++ = (char) bcm_strtoul(hex, NULL, 16);
-                       keystr += 2;
-               }
-               break;
-       default:
-               return -1;
-       }
-
-       switch (key->len) {
-       case 5:
-               key->algo = CRYPTO_ALGO_WEP1;
-               break;
-       case 13:
-               key->algo = CRYPTO_ALGO_WEP128;
-               break;
-       case 16:
-               
-               key->algo = CRYPTO_ALGO_AES_CCM;
-               break;
-       case 32:
-               key->algo = CRYPTO_ALGO_TKIP;
-               break;
-       default:
-               return -1;
-       }
-
-       
-       key->flags |= WL_PRIMARY_KEY;
-
-       return 0;
-}
-
-#ifdef EXT_WPA_CRYPTO
-#define SHA1HashSize 20
-extern void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
-                                               int iterations, u8 *buf, size_t buflen);
-
-#else
-
-#define SHA1HashSize 20
-int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, \
-                                               int iterations, u8 *buf, size_t buflen)
-{
-       WL_ERROR(("WARNING: %s is not implemented !!!\n", __FUNCTION__));
-       return -1;
-}
-
-#endif 
-
-
-int dev_iw_write_cfg1_bss_var(struct net_device *dev, int val)
-{
-       struct {
-               int cfg;
-               int val;
-       } bss_setbuf;
-
-       int bss_set_res;
-       char smbuf[WLC_IOCTL_SMLEN];
-       memset(smbuf, 0, sizeof(smbuf));
-
-       bss_setbuf.cfg = 1;
-       bss_setbuf.val = val;
-
-       bss_set_res = dev_iw_iovar_setbuf(dev, "bss",
-               &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf));
-       WL_TRACE(("%s: bss_set_result:%d set with %d\n", __FUNCTION__, bss_set_res, val));
-
-       return bss_set_res;
-}
-
-
-int dev_iw_read_cfg1_bss_var(struct net_device *dev, int *val)
-{
-       int bsscfg_idx = 1;
-       int bss_set_res;
-       char smbuf[WLC_IOCTL_SMLEN];
-       memset(smbuf, 0, sizeof(smbuf));
-
-       bss_set_res = dev_iw_iovar_getbuf(dev, "bss", \
-                &bsscfg_idx, sizeof(bsscfg_idx), smbuf, sizeof(smbuf));
-       *val = *(int*)smbuf;
-       *val = dtoh32(*val);
-       WL_TRACE(("%s: status=%d bss_get_result=%d\n", __FUNCTION__, bss_set_res, *val));
-       return bss_set_res;
-}
-
-
-
-#ifndef AP_ONLY
-static int wl_bssiovar_mkbuf(
-                       const char *iovar,
-                       int bssidx,
-                       void *param,
-                       int paramlen,
-                       void *bufptr,
-                       int buflen,
-                       int *perr)
-{
-       const char *prefix = "bsscfg:";
-       int8* p;
-       uint prefixlen;
-       uint namelen;
-       uint iolen;
-
-       prefixlen = strlen(prefix);     
-       namelen = strlen(iovar) + 1;    
-       iolen = prefixlen + namelen + sizeof(int) + paramlen;
-
-       
-       if (buflen < 0 || iolen > (uint)buflen) {
-               *perr = BCME_BUFTOOSHORT;
-               return 0;
-       }
-
-       p = (int8*)bufptr;
-
-       
-       memcpy(p, prefix, prefixlen);
-       p += prefixlen;
-
-       
-       memcpy(p, iovar, namelen);
-       p += namelen;
-
-       
-       bssidx = htod32(bssidx);
-       memcpy(p, &bssidx, sizeof(int32));
-       p += sizeof(int32);
-
-       
-       if (paramlen)
-               memcpy(p, param, paramlen);
-
-       *perr = 0;
-       return iolen;
-}
-#endif 
-
-
-
-
-int get_user_params(char *user_params, struct iw_point *dwrq)
-{
-       int ret = 0;
-
-       if (copy_from_user(user_params, dwrq->pointer, dwrq->length)) {
-               WL_ERROR(("\n%s: no user params: uptr:%p, ulen:%d\n",
-                       __FUNCTION__, dwrq->pointer, dwrq->length));
-               return -EFAULT;
-       }
-
-       WL_TRACE(("\n%s: iwpriv user params:%s\n", __FUNCTION__, user_params));
-
-       return ret;
-}
-
-
-#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
-
-#endif /* SOFTAP */
-
-
-#if defined(CSCAN)
-
-static int
-wl_iw_combined_scan_set(struct net_device *dev, wlc_ssid_t* ssids_local, int nssid, int nchan)
-{
-       int params_size = WL_SCAN_PARAMS_FIXED_SIZE + WL_NUMCHANNELS * sizeof(uint16);
-       int err = 0;
-       char *p;
-       int i;
-       iscan_info_t *iscan = g_iscan;
-
-       WL_TRACE(("%s nssid=%d nchan=%d\n", __FUNCTION__, nssid, nchan));
-
-       if ((!dev) && (!g_iscan) && (!iscan->iscan_ex_params_p)) {
-               WL_ERROR(("%s error exit\n", __FUNCTION__));
-               err = -1;
-       }
-
-       params_size += WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
-
-       
-       if (nssid > 0) {
-               i = OFFSETOF(wl_scan_params_t, channel_list) + nchan * sizeof(uint16);
-               i = ROUNDUP(i, sizeof(uint32));
-               if (i + nssid * sizeof(wlc_ssid_t) > params_size) {
-                       printf("additional ssids exceed params_size\n");
-                       err = -1;
-                       goto exit;
-               }
-
-               p = ((char*)&iscan->iscan_ex_params_p->params) + i;
-               memcpy(p, ssids_local, nssid * sizeof(wlc_ssid_t));
-               p += nssid * sizeof(wlc_ssid_t);
-       } else {
-               p = (char*)iscan->iscan_ex_params_p->params.channel_list + nchan * sizeof(uint16);
-       }
-
-       
-       iscan->iscan_ex_params_p->params.channel_num = \
-               htod32((nssid << WL_SCAN_PARAMS_NSSID_SHIFT) | \
-                                       (nchan & WL_SCAN_PARAMS_COUNT_MASK));
-
-       nssid = \
-       (uint)((iscan->iscan_ex_params_p->params.channel_num >> WL_SCAN_PARAMS_NSSID_SHIFT) & \
-                              WL_SCAN_PARAMS_COUNT_MASK);
-
-       
-       params_size = (int) (p - (char*)iscan->iscan_ex_params_p + nssid * sizeof(wlc_ssid_t));
-       iscan->iscan_ex_param_size = params_size;
-
-       iscan->list_cur = iscan->list_hdr;
-       iscan->iscan_state = ISCAN_STATE_SCANING;
-       wl_iw_set_event_mask(dev);
-       mod_timer(&iscan->timer, jiffies + iscan->timer_ms*HZ/1000);
-
-       iscan->timer_on = 1;
-
-#ifdef SCAN_DUMP
-       {
-               int i;
-               WL_SCAN(("\n### List of SSIDs to scan ###\n"));
-               for (i = 0; i < nssid; i++) {
-                       if (!ssids_local[i].SSID_len)
-                               WL_SCAN(("%d: Broadcast scan\n", i));
-                       else
-                       WL_SCAN(("%d: scan  for  %s size =%d\n", i, \
-                               ssids_local[i].SSID, ssids_local[i].SSID_len));
-               }
-               WL_SCAN(("### List of channels to scan ###\n"));
-               for (i = 0; i < nchan; i++)
-               {
-                       WL_SCAN(("%d ", iscan->iscan_ex_params_p->params.channel_list[i]));
-               }
-               WL_SCAN(("\nnprobes=%d\n", iscan->iscan_ex_params_p->params.nprobes));
-               WL_SCAN(("active_time=%d\n", iscan->iscan_ex_params_p->params.active_time));
-               WL_SCAN(("passive_time=%d\n", iscan->iscan_ex_params_p->params.passive_time));
-               WL_SCAN(("home_time=%d\n", iscan->iscan_ex_params_p->params.home_time));
-               WL_SCAN(("scan_type=%d\n", iscan->iscan_ex_params_p->params.scan_type));
-               WL_SCAN(("\n###################\n"));
-       }
-#endif 
-
-       if (params_size > WLC_IOCTL_MEDLEN) {
-                       WL_ERROR(("Set ISCAN for %s due to params_size=%d  \n", \
-                               __FUNCTION__, params_size));
-                       err = -1;
-       }
-
-       if ((err = dev_iw_iovar_setbuf(dev, "iscan", iscan->iscan_ex_params_p, \
-                       iscan->iscan_ex_param_size, \
-                       iscan->ioctlbuf, sizeof(iscan->ioctlbuf)))) {
-                       WL_TRACE(("Set ISCAN for %s failed with %d\n", __FUNCTION__, err));
-                       err = -1;
-       }
-
-exit:
-
-       return err;
-}
-
-
-static int iwpriv_set_cscan(struct net_device *dev, struct iw_request_info *info, \
-                               union iwreq_data *wrqu, char *ext)
-{
-       int res = 0;
-       char  *extra = NULL;
-       iscan_info_t *iscan = g_iscan;
-       wlc_ssid_t ssids_local[WL_SCAN_PARAMS_SSID_MAX];
-       int nssid = 0;
-       int nchan = 0;
-
-       WL_TRACE(("\%s: info->cmd:%x, info->flags:%x, u.data=0x%p, u.len=%d\n",
-               __FUNCTION__, info->cmd, info->flags,
-               wrqu->data.pointer, wrqu->data.length));
-
-       if (g_onoff == G_WLAN_SET_OFF) {
-               WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
-               return -1;
-       }
-
-       if (wrqu->data.length != 0) {
-
-               char *str_ptr;
-
-               if (!iscan->iscan_ex_params_p) {
-                       return -EFAULT;
-               }
-
-               if (!(extra = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
-                       return -ENOMEM;
-
-               if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
-                       kfree(extra);
-                       return -EFAULT;
-               }
-
-               extra[wrqu->data.length] = 0;
-               WL_ERROR(("Got str param in iw_point:\n %s\n", extra));
-
-               str_ptr = extra;
-
-               
-               if (strncmp(str_ptr, GET_SSID, strlen(GET_SSID))) {
-                       WL_ERROR(("%s Error: extracting SSID='' string\n", __FUNCTION__));
-                       goto exit_proc;
-               }
-               str_ptr += strlen(GET_SSID);
-               nssid = wl_iw_parse_ssid_list(&str_ptr, ssids_local, nssid, \
-                                               WL_SCAN_PARAMS_SSID_MAX);
-               if (nssid == -1) {
-                       WL_ERROR(("%s wrong ssid list", __FUNCTION__));
-                       return -1;
-               }
-
-               memset(iscan->iscan_ex_params_p, 0, iscan->iscan_ex_param_size);
-               ASSERT(iscan->iscan_ex_param_size < WLC_IOCTL_MAXLEN);
-
-               
-               wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, NULL);
-               iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
-               iscan->iscan_ex_params_p->action = htod16(WL_SCAN_ACTION_START);
-               iscan->iscan_ex_params_p->scan_duration = htod16(0);
-
-               
-               if ((nchan = wl_iw_parse_channel_list(&str_ptr, \
-                                       &iscan->iscan_ex_params_p->params.channel_list[0], \
-                                       WL_NUMCHANNELS)) == -1) {
-                       WL_ERROR(("%s missing channel list\n", __FUNCTION__));
-                       return -1;
-               }
-
-               
-               get_parmeter_from_string(&str_ptr, \
-                               GET_NPROBE, PTYPE_INTDEC, \
-                               &iscan->iscan_ex_params_p->params.nprobes, 2);
-
-               get_parmeter_from_string(&str_ptr, GET_ACTIVE_ASSOC_DWELL, PTYPE_INTDEC, \
-                                               &iscan->iscan_ex_params_p->params.active_time, 4);
-
-               get_parmeter_from_string(&str_ptr, GET_PASSIVE_ASSOC_DWELL, PTYPE_INTDEC, \
-                                               &iscan->iscan_ex_params_p->params.passive_time, 4);
-
-               get_parmeter_from_string(&str_ptr, GET_HOME_DWELL, PTYPE_INTDEC, \
-                                       &iscan->iscan_ex_params_p->params.home_time, 4);
-
-               get_parmeter_from_string(&str_ptr, GET_SCAN_TYPE, PTYPE_INTDEC, \
-                                       &iscan->iscan_ex_params_p->params.scan_type, 1);
-
-               
-               res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
-
-       } else {
-                
-                 WL_ERROR(("IWPRIV argument len = 0 \n"));
-                 return -1;
-       }
-
-exit_proc:
-
-       kfree(extra);
-
-       return res;
-}
-
-
-static int
-wl_iw_set_cscan(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *extra
-)
-{
-       int res = -1;
-       iscan_info_t *iscan = g_iscan;
-       wlc_ssid_t ssids_local[WL_SCAN_PARAMS_SSID_MAX];
-       int nssid = 0;
-       int nchan = 0;
-       cscan_tlv_t *cscan_tlv_temp;
-       char type;
-       char *str_ptr;
-       int tlv_size_left;
-#ifdef TLV_DEBUG
-       int i;
-       char tlv_in_example[] = {                       'C', 'S', 'C', 'A', 'N', ' ', \
-                                                       0x53, 0x01, 0x00, 0x00,
-                                                       'S',      
-                                                       0x00, 
-                                                       'S',    
-                                                       0x04, 
-                                                       'B', 'R', 'C', 'M',
-                                                       'C',
-                                                       0x06, 
-                                                       'P', 
-                                                       0x94,
-                                                       0x11,
-                                                       'T',     
-                                                       0x01  
-                                                       };
-#endif 
-
-       WL_TRACE(("\n### %s: info->cmd:%x, info->flags:%x, u.data=0x%p, u.len=%d\n",
-               __FUNCTION__, info->cmd, info->flags,
-               wrqu->data.pointer, wrqu->data.length));
-
-       if (g_onoff == G_WLAN_SET_OFF) {
-               WL_TRACE(("%s: driver is not up yet after START\n", __FUNCTION__));
-               return -1;
-       }
-
-       if (wrqu->data.length < (strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t))) {
-               WL_ERROR(("%s aggument=%d  less %d\n", __FUNCTION__, \
-                       wrqu->data.length, strlen(CSCAN_COMMAND) + sizeof(cscan_tlv_t)));
-               return -1;
-       }
-
-#ifdef TLV_DEBUG
-       memcpy(extra, tlv_in_example, sizeof(tlv_in_example));
-       wrqu->data.length = sizeof(tlv_in_example);
-       for (i = 0; i < wrqu->data.length; i++)
-               printf("%02X ", extra[i]);
-       printf("\n");
-#endif 
-
-       str_ptr = extra;
-       str_ptr +=  strlen(CSCAN_COMMAND);
-       tlv_size_left = wrqu->data.length - strlen(CSCAN_COMMAND);
-
-       cscan_tlv_temp = (cscan_tlv_t *)str_ptr;
-       memset(ssids_local, 0, sizeof(ssids_local));
-       
-       if ((cscan_tlv_temp->prefix == CSCAN_TLV_PREFIX) && \
-               (cscan_tlv_temp->version == CSCAN_TLV_VERSION) && \
-               (cscan_tlv_temp->subver == CSCAN_TLV_SUBVERSION))
-       {
-               str_ptr += sizeof(cscan_tlv_t);
-               tlv_size_left  -= sizeof(cscan_tlv_t);
-
-               
-               if ((nssid = wl_iw_parse_ssid_list_tlv(&str_ptr, ssids_local, \
-                               WL_SCAN_PARAMS_SSID_MAX, &tlv_size_left)) <= 0) {
-                       WL_ERROR(("SSID is not presented or corrupted ret=%d\n", nssid));
-                       goto exit_proc;
-               }
-               else {
-                       
-                       memset(iscan->iscan_ex_params_p, 0, iscan->iscan_ex_param_size);
-
-                       
-                       wl_iw_iscan_prep(&iscan->iscan_ex_params_p->params, NULL);
-                       iscan->iscan_ex_params_p->version = htod32(ISCAN_REQ_VERSION);
-                       iscan->iscan_ex_params_p->action = htod16(WL_SCAN_ACTION_START);
-                       iscan->iscan_ex_params_p->scan_duration = htod16(0);
-
-                       
-                       while (tlv_size_left > 0)
-                       {
-                       type = str_ptr[0];
-                       switch (type) {
-                               case CSCAN_TLV_TYPE_CHANNEL_IE:
-                                       
-                                       if ((nchan = wl_iw_parse_channel_list_tlv(&str_ptr, \
-                                       &iscan->iscan_ex_params_p->params.channel_list[0], \
-                                       WL_NUMCHANNELS, &tlv_size_left)) == -1) {
-                                       WL_ERROR(("%s missing channel list\n", \
-                                                __FUNCTION__));
-                                               goto exit_proc;
-                                       }
-                               break;
-                               case CSCAN_TLV_TYPE_NPROBE_IE:
-                                       if ((res = wl_iw_parse_data_tlv(&str_ptr, \
-                                               &iscan->iscan_ex_params_p->params.nprobes, \
-                                               sizeof(iscan->iscan_ex_params_p->params.nprobes), \
-                                               type, sizeof(char), &tlv_size_left)) == -1) {
-                                               WL_ERROR(("%s return %d\n", \
-                                                       __FUNCTION__, res));
-                                                       goto exit_proc;
-                                       }
-                               break;
-                               case CSCAN_TLV_TYPE_ACTIVE_IE:
-                                       if ((res = wl_iw_parse_data_tlv(&str_ptr, \
-                                       &iscan->iscan_ex_params_p->params.active_time, \
-                                       sizeof(iscan->iscan_ex_params_p->params.active_time), \
-                                       type, sizeof(short), &tlv_size_left)) == -1) {
-                                               WL_ERROR(("%s return %d\n", \
-                                               __FUNCTION__, res));
-                                               goto exit_proc;
-                                       }
-                               break;
-                               case CSCAN_TLV_TYPE_PASSIVE_IE:
-                                       if ((res = wl_iw_parse_data_tlv(&str_ptr, \
-                                       &iscan->iscan_ex_params_p->params.passive_time, \
-                                       sizeof(iscan->iscan_ex_params_p->params.passive_time), \
-                                       type, sizeof(short), &tlv_size_left)) == -1) {
-                                               WL_ERROR(("%s return %d\n", \
-                                               __FUNCTION__, res));
-                                               goto exit_proc;
-                                       }
-                               break;
-                               case CSCAN_TLV_TYPE_HOME_IE:
-                                       if ((res = wl_iw_parse_data_tlv(&str_ptr, \
-                                       &iscan->iscan_ex_params_p->params.home_time, \
-                                       sizeof(iscan->iscan_ex_params_p->params.home_time), \
-                                       type, sizeof(short), &tlv_size_left)) == -1) {
-                                               WL_ERROR(("%s return %d\n", \
-                                               __FUNCTION__, res));
-                                               goto exit_proc;
-                                       }
-                               break;
-                               case CSCAN_TLV_TYPE_STYPE_IE:
-                                       if ((res = wl_iw_parse_data_tlv(&str_ptr, \
-                                       &iscan->iscan_ex_params_p->params.scan_type, \
-                                       sizeof(iscan->iscan_ex_params_p->params.scan_type), \
-                                       type, sizeof(char), &tlv_size_left)) == -1) {
-                                       WL_ERROR(("%s return %d\n", \
-                                               __FUNCTION__, res));
-                                               goto exit_proc;
-                                       }
-                               break;
-
-                               default :
-                                       WL_ERROR(("%s get unkwown type %X\n", \
-                                               __FUNCTION__, type));
-                                       goto exit_proc;
-                               break;
-                               }
-                       } 
-                       }
-               }
-               else {
-                       WL_ERROR(("%s get wrong TLV command\n", __FUNCTION__));
-                       goto exit_proc;
-               }
-
-               
-               res = wl_iw_combined_scan_set(dev, ssids_local, nssid, nchan);
-
-exit_proc:
-       return res;
-}
-
-#endif 
-
-
-
-#ifdef SOFTAP
-
-#ifndef AP_ONLY
-static int thr_wait_for_2nd_eth_dev(void *data)
-{
-       int ret = 0;
-
-       printk("==========> WARNING!!! we are in thr_wait_for_2nd_eth_dev!!!\n");
-
-       DAEMONIZE("wl0_eth_wthread");
-
-       WL_TRACE(("\n>%s threda started:, PID:%x\n", __FUNCTION__, current->pid));
-
-/*     if (down_timeout(&ap_eth_sema,  msecs_to_jiffies(5000)) != 0) {
-               WL_ERROR(("\n%s: sap_eth_sema timeout \n", __FUNCTION__));
-               ret = -1;
-               goto fail;
-       }
-*/
-       if (!ap_net_dev) {
-               WL_ERROR((" ap_net_dev is null !!!"));
-               ret = -1;
-               goto fail;
-       }
-
-       WL_TRACE(("\n>%s: Thread:'softap ethdev IF:%s is detected !!!'\n\n",
-               __FUNCTION__, ap_net_dev->name));
-
-       ap_cfg_running = TRUE;
-
-       bcm_mdelay(500); 
-
-       
-       wl_iw_send_priv_event(priv_dev, "AP_SET_CFG_OK");
-
-fail:
-
-       WL_TRACE(("\n>%s, thread completed\n", __FUNCTION__));
-
-       return ret;
-}
-#endif
-
-#ifndef AP_ONLY
-static int last_auto_channel = 6;
-#endif
-static int get_softap_auto_channel(struct net_device *dev, struct ap_profile *ap)
-{
-       int chosen = 0;
-       wl_uint32_list_t request;
-       int rescan = 0;
-       int retry = 0;
-       int updown = 0;
-       int ret = 0;
-       wlc_ssid_t null_ssid;
-       int res = 0;
-#ifndef AP_ONLY
-       int iolen = 0;
-       int mkvar_err = 0;
-       int bsscfg_index = 1;
-       char buf[WLC_IOCTL_SMLEN];
-#endif
-       WL_SOFTAP(("Enter %s\n", __FUNCTION__));
-
-#ifndef AP_ONLY
-       if (ap_cfg_running) {
-               ap->channel = last_auto_channel;
-               return res;
-       }
-#endif
-       memset(&null_ssid, 0, sizeof(wlc_ssid_t));
-       res |= dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown));
-#ifdef AP_ONLY
-       res |= dev_wlc_ioctl(dev, WLC_SET_SSID, &null_ssid, sizeof(null_ssid));
-#else
-       iolen = wl_bssiovar_mkbuf("ssid", bsscfg_index, (char *)(&null_ssid), \
-               null_ssid.SSID_len+4, buf, sizeof(buf), &mkvar_err);
-       ASSERT(iolen);
-       res |= dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen);
-#endif
-       auto_channel_retry:
-                       request.count = htod32(0);
-                       ret = dev_wlc_ioctl(dev, WLC_START_CHANNEL_SEL, &request, sizeof(request));
-                       if (ret < 0) {
-                               WL_ERROR(("can't start auto channel scan\n"));
-                               goto fail;
-                       }
-
-       get_channel_retry:
-                       bcm_mdelay(500);
-
-                       ret = dev_wlc_ioctl(dev, WLC_GET_CHANNEL_SEL, &chosen, sizeof(chosen));
-                       if (ret < 0 || dtoh32(chosen) == 0) {
-                               if (retry++ < 3)
-                                       goto get_channel_retry;
-                               else {
-                                       WL_ERROR(("can't get auto channel sel, err = %d, \
-                                               chosen = %d\n", ret, chosen));
-                                       goto fail;
-                               }
-                       }
-                       if ((chosen == 1) && (!rescan++))
-                               goto auto_channel_retry;
-                       WL_SOFTAP(("Set auto channel = %d\n", chosen));
-                       ap->channel = chosen;
-                       if ((res = dev_wlc_ioctl(dev, WLC_DOWN, &updown, sizeof(updown))) < 0) {
-                               WL_ERROR(("%s fail to set up err =%d\n", __FUNCTION__, res));
-                               goto fail;
-                       }
-#ifndef AP_ONLY
-       if (!res)
-               last_auto_channel = ap->channel;
-#endif
-
-fail :
-       return res;
-} 
-
-
-static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
-{
-       int updown = 0;
-       int channel = 0;
-
-       wlc_ssid_t ap_ssid;
-       int max_assoc = 8;
-
-       int res = 0;
-       int apsta_var = 0;
-#ifndef AP_ONLY
-       int mpc = 0;
-       int iolen = 0;
-       int mkvar_err = 0;
-       int bsscfg_index = 1;
-       char buf[WLC_IOCTL_SMLEN];
-#endif
-       wl_iw_t *iw;
-
-       if (!dev) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return -1;
-       }
-
-       WL_SOFTAP(("wl_iw: set ap profile:\n"));
-       WL_SOFTAP(("    ssid = '%s'\n", ap->ssid));
-       WL_SOFTAP(("    security = '%s'\n", ap->sec));
-       if (ap->key[0] != '\0')
-               WL_SOFTAP(("    key = '%s'\n", ap->key));
-       WL_SOFTAP(("    channel = %d\n", ap->channel));
-       WL_SOFTAP(("    max scb = %d\n", ap->max_scb));
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK_SOFTAP_SET(iw->pub);
-       WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_SET, "SoftAP_SET");
-       WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
-
-#ifdef AP_ONLY
-       if (ap_cfg_running) {
-               wl_iw_softap_deassoc_stations(dev);
-               ap_cfg_running = FALSE;
-       }
-#endif 
-
-       
-       if (ap_cfg_running == FALSE) {
-
-#ifndef AP_ONLY
-
-               
-               sema_init(&ap_eth_sema, 0);
-
-               mpc = 0;
-               if ((res = dev_wlc_intvar_set(dev, "mpc", mpc))) {
-                       WL_ERROR(("%s fail to set mpc\n", __FUNCTION__));
-                       goto fail;
-               }
-#endif
-
-               updown = 0;
-               if ((res = dev_wlc_ioctl(dev, WLC_DOWN, &updown, sizeof(updown)))) {
-                       WL_ERROR(("%s fail to set updown\n", __FUNCTION__));
-                       goto fail;
-               }
-
-#ifdef AP_ONLY
-               
-               apsta_var = 0;
-               if ((res = dev_wlc_ioctl(dev, WLC_SET_AP, &apsta_var, sizeof(apsta_var)))) {
-                       WL_ERROR(("%s fail to set apsta_var 0\n", __FUNCTION__));
-                       goto fail;
-               }
-               apsta_var = 1;
-               if ((res = dev_wlc_ioctl(dev, WLC_SET_AP, &apsta_var, sizeof(apsta_var)))) {
-                       WL_ERROR(("%s fail to set apsta_var 1\n", __FUNCTION__));
-                       goto fail;
-               }
-               res = dev_wlc_ioctl(dev, WLC_GET_AP, &apsta_var, sizeof(apsta_var));
-#else
-               
-               apsta_var = 1;
-               iolen = wl_bssiovar_mkbuf("apsta",
-                       bsscfg_index,  &apsta_var, sizeof(apsta_var)+4,
-                       buf, sizeof(buf), &mkvar_err);
-               ASSERT(iolen);
-               if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) < 0) {
-                       WL_ERROR(("%s fail to set apsta \n", __FUNCTION__));
-                       goto fail;
-               }
-               WL_TRACE(("\n>in %s: apsta set result: %d \n", __FUNCTION__, res));
-#endif 
-
-               updown = 1;
-               if ((res = dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown))) < 0) {
-                       WL_ERROR(("%s fail to set apsta \n", __FUNCTION__));
-                       goto fail;
-               }
-
-       } else {
-               
-               if (!ap_net_dev) {
-                       WL_ERROR(("%s: ap_net_dev is null\n", __FUNCTION__));
-                       goto fail;
-               }
-
-               res = wl_iw_softap_deassoc_stations(ap_net_dev);
-
-               
-               if ((res = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
-                       WL_ERROR(("%s fail to set bss down\n", __FUNCTION__));
-                       goto fail;
-               }
-       }
-
-       
-       if ((ap->channel == 0) && (get_softap_auto_channel(dev, ap) < 0)) {
-               ap->channel = 1;
-               WL_ERROR(("%s auto channel failed, pick up channel=%d\n", \
-                       __FUNCTION__, ap->channel));
-
-       }
-
-       channel = ap->channel;
-       if ((res = dev_wlc_ioctl(dev, WLC_SET_CHANNEL, &channel, sizeof(channel)))) {
-                       WL_ERROR(("%s fail to set channel\n", __FUNCTION__));
-                       goto fail;
-       }
-
-       if (ap_cfg_running == FALSE) {
-               updown = 0;
-               if ((res = dev_wlc_ioctl(dev, WLC_UP, &updown, sizeof(updown)))) {
-                       WL_ERROR(("%s fail to set up\n", __FUNCTION__));
-                       goto fail;
-               }
-       }
-
-       max_assoc = ap->max_scb;
-       if ((res = dev_wlc_intvar_set(dev, "maxassoc", max_assoc))) {
-                       WL_ERROR(("%s fail to set maxassoc\n", __FUNCTION__));
-                       goto fail;
-       }
-
-       ap_ssid.SSID_len = strlen(ap->ssid);
-       strncpy(ap_ssid.SSID, ap->ssid, ap_ssid.SSID_len);
-
-       
-#ifdef AP_ONLY
-       if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
-               WL_ERROR(("ERROR:%d in:%s, wl_iw_set_ap_security is skipped\n", \
-               res, __FUNCTION__));
-               goto fail;
-       }
-       wl_iw_send_priv_event(dev, "ASCII_CMD=AP_BSS_START");
-       ap_cfg_running = TRUE;
-#else
-
-       iolen = wl_bssiovar_mkbuf("ssid", bsscfg_index, (char *)(&ap_ssid),
-               ap_ssid.SSID_len+4, buf, sizeof(buf), &mkvar_err);
-       ASSERT(iolen);
-       if ((res = dev_wlc_ioctl(dev, WLC_SET_VAR, buf, iolen)) != 0) {
-               WL_ERROR(("ERROR:%d in:%s, Security & BSS reconfiguration is skipped\n", \
-               res, __FUNCTION__));
-               goto fail;
-       }
-       if (ap_cfg_running == FALSE) {
-               
-               kernel_thread(thr_wait_for_2nd_eth_dev, 0, 0);
-       } else {
-
-               
-               if (ap_net_dev == NULL) {
-                       WL_ERROR(("%s ERROR: ap_net_dev is NULL !!!\n", __FUNCTION__));
-                       goto fail;
-               }
-
-               WL_ERROR(("%s: %s Configure security & restart AP bss \n", \
-                        __FUNCTION__, ap_net_dev->name));
-
-               
-               if ((res = wl_iw_set_ap_security(ap_net_dev, &my_ap)) < 0) {
-                       WL_ERROR(("%s fail to set security : %d\n", __FUNCTION__, res));
-                       goto fail;
-               }
-
-               
-               if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0) {
-                       WL_ERROR(("%s fail to set bss up\n", __FUNCTION__));
-                       goto fail;
-               }
-       }
-#endif 
-fail:
-       WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_SET);
-       WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_SET);
-       MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
-       WL_SOFTAP(("%s exit with %d\n", __FUNCTION__, res));
-       return res;
-}
-
-
-static int wl_iw_set_ap_security(struct net_device *dev, struct ap_profile *ap)
-{
-       int wsec = 0;
-       int wpa_auth = 0;
-       int res = 0;
-       int i;
-       char *ptr;
-#ifdef AP_ONLY
-       int mpc = 0;
-       wlc_ssid_t ap_ssid;
-#endif
-       wl_wsec_key_t key;
-
-       WL_SOFTAP(("\nsetting SOFTAP security mode:\n"));
-       WL_SOFTAP(("wl_iw: set ap profile:\n"));
-       WL_SOFTAP(("    ssid = '%s'\n", ap->ssid));
-       WL_SOFTAP(("    security = '%s'\n", ap->sec));
-       if (ap->key[0] != '\0')
-               WL_SOFTAP(("    key = '%s'\n", ap->key));
-       WL_SOFTAP(("    channel = %d\n", ap->channel));
-       WL_SOFTAP(("    max scb = %d\n", ap->max_scb));
-
-
-       if (strnicmp(ap->sec, "open", strlen("open")) == 0) {
-
-          
-               wsec = 0;
-               res = dev_wlc_intvar_set(dev, "wsec", wsec);
-               wpa_auth = WPA_AUTH_DISABLED;
-               res |= dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
-               WL_SOFTAP(("=====================\n"));
-               WL_SOFTAP((" wsec & wpa_auth set 'OPEN', result:&d %d\n", res));
-               WL_SOFTAP(("=====================\n"));
-
-       } else if (strnicmp(ap->sec, "wep", strlen("wep")) == 0) {
-
-          
-               memset(&key, 0, sizeof(key));
-
-               wsec = WEP_ENABLED;
-               res = dev_wlc_intvar_set(dev, "wsec", wsec);
-
-               key.index = 0;
-               if (wl_iw_parse_wep(ap->key, &key)) {
-                       WL_SOFTAP(("wep key parse err!\n"));
-                       return -1;
-               }
-
-               key.index = htod32(key.index);
-               key.len = htod32(key.len);
-               key.algo = htod32(key.algo);
-               key.flags = htod32(key.flags);
-
-               res |= dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
-
-               wpa_auth = WPA_AUTH_DISABLED;
-               res |= dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
-               WL_SOFTAP(("=====================\n"));
-               WL_SOFTAP((" wsec & auth set 'WEP', result:&d %d\n", res));
-               WL_SOFTAP(("=====================\n"));
-
-       } else if (strnicmp(ap->sec, "wpa2-psk", strlen("wpa2-psk")) == 0) {
-
-          
-
-               wsec_pmk_t psk;
-               size_t key_len;
-
-               wsec = AES_ENABLED;
-               dev_wlc_intvar_set(dev, "wsec", wsec);
-
-               key_len = strlen(ap->key);
-               if (key_len < WSEC_MIN_PSK_LEN || key_len > WSEC_MAX_PSK_LEN) {
-                       WL_SOFTAP(("passphrase must be between %d and %d characters long\n",
-                       WSEC_MIN_PSK_LEN, WSEC_MAX_PSK_LEN));
-                       return -1;
-               }
-
-               
-               if (key_len < WSEC_MAX_PSK_LEN) {
-                       unsigned char output[2*SHA1HashSize];
-                       char key_str_buf[WSEC_MAX_PSK_LEN+1];
-
-                       
-                       memset(output, 0, sizeof(output));
-                       pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-                       
-                       ptr = key_str_buf;
-                       for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
-                               
-                               sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
-                                        (uint)output[i*4+1], (uint)output[i*4+2], \
-                                        (uint)output[i*4+3]);
-                               ptr += 8;
-                       }
-                       WL_SOFTAP(("%s: passphase = %s\n", __FUNCTION__, key_str_buf));
-
-                       psk.key_len = htod16((ushort)WSEC_MAX_PSK_LEN);
-                       memcpy(psk.key, key_str_buf, psk.key_len);
-               } else {
-                       psk.key_len = htod16((ushort) key_len);
-                       memcpy(psk.key, ap->key, key_len);
-               }
-               psk.flags = htod16(WSEC_PASSPHRASE);
-               dev_wlc_ioctl(dev, WLC_SET_WSEC_PMK, &psk, sizeof(psk));
-
-               wpa_auth = WPA2_AUTH_PSK;
-               dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
-       } else if (strnicmp(ap->sec, "wpa-psk", strlen("wpa-psk")) == 0) {
-
-               
-               wsec_pmk_t psk;
-               size_t key_len;
-
-               wsec = TKIP_ENABLED;
-               res = dev_wlc_intvar_set(dev, "wsec", wsec);
-
-               key_len = strlen(ap->key);
-               if (key_len < WSEC_MIN_PSK_LEN || key_len > WSEC_MAX_PSK_LEN) {
-                       WL_SOFTAP(("passphrase must be between %d and %d characters long\n",
-                       WSEC_MIN_PSK_LEN, WSEC_MAX_PSK_LEN));
-                       return -1;
-               }
-
-               
-               if (key_len < WSEC_MAX_PSK_LEN) {
-                       unsigned char output[2*SHA1HashSize];
-                       char key_str_buf[WSEC_MAX_PSK_LEN+1];
-
-                       WL_SOFTAP(("%s: do passhash...\n", __FUNCTION__));
-                       
-                       pbkdf2_sha1(ap->key, ap->ssid, strlen(ap->ssid), 4096, output, 32);
-                       
-                       ptr = key_str_buf;
-                       for (i = 0; i < (WSEC_MAX_PSK_LEN/8); i++) {
-                               WL_SOFTAP(("[%02d]: %08x\n", i, *((unsigned int*)&output[i*4])));
-                               
-                               sprintf(ptr, "%02x%02x%02x%02x", (uint)output[i*4], \
-                                       (uint)output[i*4+1], (uint)output[i*4+2], \
-                                        (uint)output[i*4+3]);
-                               ptr += 8;
-                       }
-                       printk("%s: passphase = %s\n", __FUNCTION__, key_str_buf);
-
-                       psk.key_len = htod16((ushort)WSEC_MAX_PSK_LEN);
-                       memcpy(psk.key, key_str_buf, psk.key_len);
-               } else {
-                       psk.key_len = htod16((ushort) key_len);
-                       memcpy(psk.key, ap->key, key_len);
-               }
-
-               psk.flags = htod16(WSEC_PASSPHRASE);
-               res |= dev_wlc_ioctl(dev, WLC_SET_WSEC_PMK, &psk, sizeof(psk));
-
-               wpa_auth = WPA_AUTH_PSK;
-               res |= dev_wlc_intvar_set(dev, "wpa_auth", wpa_auth);
-
-               WL_SOFTAP((" wsec & auth set 'wpa-psk' (TKIP), result:&d %d\n", res));
-       }
-
-#ifdef AP_ONLY
-               ap_ssid.SSID_len = strlen(ap->ssid);
-               strncpy(ap_ssid.SSID, ap->ssid, ap_ssid.SSID_len);
-               res |= dev_wlc_ioctl(dev, WLC_SET_SSID, &ap_ssid, sizeof(ap_ssid));
-               mpc = 0;
-               res |= dev_wlc_intvar_set(dev, "mpc", mpc);
-               if (strnicmp(ap->sec, "wep", strlen("wep")) == 0) {
-                       res |= dev_wlc_ioctl(dev, WLC_SET_KEY, &key, sizeof(key));
-               }
-#endif
-       return res;
-}
-
-
-static int wl_iw_softap_deassoc_stations(struct net_device *dev)
-{
-       int i;
-       int res = 0;
-
-       char mac_buf[128] = {0};
-       struct maclist *assoc_maclist = (struct maclist *) mac_buf;
-
-       memset(assoc_maclist, 0, sizeof(mac_buf));
-       assoc_maclist->count = 8; 
-
-       res = dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 128);
-       if (res != 0) {
-
-               WL_SOFTAP((" Error:%d in :%s, Couldn't get ASSOC List\n", res, __FUNCTION__));
-               return res;
-       }
-
-               if (assoc_maclist->count)
-                       for (i = 0; i < assoc_maclist->count; i++) {
-                       scb_val_t scbval;
-                       scbval.val = htod32(1);
-                       
-                       bcopy(&assoc_maclist->ea[i], &scbval.ea, ETHER_ADDR_LEN);
-
-                       WL_SOFTAP(("deauth STA:%d \n", i));
-                       res |= dev_wlc_ioctl(dev, WLC_SCB_DEAUTHENTICATE_FOR_REASON,
-                               &scbval, sizeof(scb_val_t));
-
-               } else WL_SOFTAP((" STA ASSOC list is empty\n"));
-
-
-       if (res != 0)
-               WL_SOFTAP((" Error:%d in :%s\n", res, __FUNCTION__));
-       else if (assoc_maclist->count) {
-               
-               bcm_mdelay(200);
-       }
-       return res;
-}
-
-
-
-static int iwpriv_softap_stop(struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *ext)
-{
-       int res = 0;
-       wl_iw_t *iw;
-
-       WL_SOFTAP(("got iwpriv AP_BSS_STOP \n"));
-
-       if ((!dev) && (!ap_net_dev)) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return res;
-       }
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK_SOFTAP_SET(iw->pub);
-       WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_STOP, "SoftAP_STOP");
-       WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
-
-       if  ((ap_cfg_running == TRUE)) {
-#ifdef AP_ONLY
-                wl_iw_softap_deassoc_stations(dev);
-#else
-                wl_iw_softap_deassoc_stations(ap_net_dev);
-
-               if ((res = dev_iw_write_cfg1_bss_var(dev, 2)) < 0)
-                       WL_ERROR(("%s failed to del BSS err = %d", __FUNCTION__, res));
-#endif
-
-               
-               bcm_mdelay(100);
-
-               wrqu->data.length = 0;
-               ap_cfg_running = FALSE;
-       }
-       else
-               WL_ERROR(("%s: was called when SoftAP is OFF : move on\n", __FUNCTION__));
-
-       WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_STOP);
-       WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_STOP);
-       MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-
-       WL_SOFTAP(("%s Done with %d\n", __FUNCTION__, res));
-       return res;
-}
-
-
-
-static int iwpriv_fw_reload(struct net_device *dev,
-       struct iw_request_info *info,
-       union iwreq_data *wrqu,
-       char *ext)
-{
-
-       int ret = -1;
-       char extra[256];
-       char *fwstr = fw_path ; 
-
-       WL_SOFTAP(("current firmware_path[]=%s\n", fwstr));
-
-       WL_TRACE((">Got FW_RELOAD cmd:"
-                               "info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d, \
-                               fw_path:%p, len:%d \n",
-                               info->cmd, info->flags,
-                               wrqu->data.pointer, wrqu->data.length, fwstr, strlen(fwstr)));
-
-
-       if ((wrqu->data.length > 4) && (wrqu->data.length < sizeof(extra))) {
-
-               char *str_ptr;
-
-               if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) {
-                       ret = -EFAULT;
-                       goto exit_proc;
-               }
-
-               
-               extra[wrqu->data.length] = 8;
-               str_ptr = extra;
-
-               if (get_parmeter_from_string(&str_ptr, "FW_PATH=", PTYPE_STRING, fwstr, 255) != 0) {
-                       WL_ERROR(("Error: extracting FW_PATH='' string\n"));
-                       goto exit_proc;
-               }
-
-               if  (strstr(fwstr, "apsta") != NULL) {
-                         WL_SOFTAP(("GOT APSTA FIRMWARE\n"));
-                         ap_fw_loaded = TRUE;
-               } else {
-                       WL_SOFTAP(("GOT STA FIRMWARE\n"));
-                       ap_fw_loaded = FALSE;
-               }
-
-               WL_SOFTAP(("SET firmware_path[]=%s , str_p:%p\n", fwstr, fwstr));
-               ret = 0;
-       } else {
-               WL_ERROR(("Error: ivalid param len:%d\n", wrqu->data.length));
-       }
-
-exit_proc:
-       return ret;
-}
-#ifdef SOFTAP
-
-static int iwpriv_wpasupp_loop_tst(struct net_device *dev,
-            struct iw_request_info *info,
-            union iwreq_data *wrqu,
-            char *ext)
-{
-       int res = 0;
-       char  *params = NULL;
-
-       WL_TRACE((">Got IWPRIV  wp_supp loopback cmd test:"
-                               "info->cmd:%x, info->flags:%x, u.data:%p, u.len:%d\n",
-                               info->cmd, info->flags,
-                               wrqu->data.pointer, wrqu->data.length));
-
-       if (wrqu->data.length != 0) {
-
-               if (!(params = kmalloc(wrqu->data.length+1, GFP_KERNEL)))
-                       return -ENOMEM;
-
-
-               if (copy_from_user(params, wrqu->data.pointer, wrqu->data.length)) {
-                       kfree(params);
-                       return -EFAULT;
-               }
-
-               params[wrqu->data.length] = 0;
-               WL_SOFTAP(("\n>> copied from user:\n %s\n", params));
-       } else {
-               WL_ERROR(("ERROR param length is 0\n"));
-               return -EFAULT;
-       }
-
-       
-       res = wl_iw_send_priv_event(dev, params);
-       kfree(params);
-
-       return res;
-}
-#endif 
-
-
-static int
-       iwpriv_en_ap_bss(
-               struct net_device *dev,
-               struct iw_request_info *info,
-               void *wrqu,
-               char *extra)
-{
-       int res = 0;
-       wl_iw_t *iw;
-
-       if (!dev) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return -1;
-       }
-
-       WL_TRACE(("%s: rcvd IWPRIV IOCTL:  for dev:%s\n", __FUNCTION__, dev->name));
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       MUTEX_LOCK_SOFTAP_SET(iw->pub);
-       WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_SOFTAP_START, "SoftAP_START");
-       WAKE_LOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
-
-       
-#ifndef AP_ONLY
-       if ((res = wl_iw_set_ap_security(dev, &my_ap)) != 0) {
-               WL_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
-       }
-       else {
-               
-               if ((res = dev_iw_write_cfg1_bss_var(dev, 1)) < 0)
-                       WL_ERROR(("%s fail to set bss up err=%d\n", __FUNCTION__, res));
-               else
-                       
-                       bcm_mdelay(100);
-       }
-
-#endif 
-
-       WL_SOFTAP(("%s done with res %d \n", __FUNCTION__, res));
-       WAKE_UNLOCK(iw->pub, WAKE_LOCK_SOFTAP_START);
-       WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_SOFTAP_START);
-       MUTEX_UNLOCK_SOFTAP_SET(iw->pub);
-       return res;
-}
-
-static int
-get_assoc_sta_list(struct net_device *dev, char *buf, int len)
-{
-       
-       WL_TRACE(("calling dev_wlc_ioctl(dev:%p, cmd:%d, buf:%p, len:%d)\n",
-               dev, WLC_GET_ASSOCLIST, buf, len));
-
-       dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, buf, len);
-
-       return 0;
-}
-
-
-static int
-set_ap_mac_list(struct net_device *dev, char *buf)
-{
-       struct mac_list_set *mac_list_set = (struct mac_list_set *)buf;
-       struct maclist *white_maclist = (struct maclist *)&mac_list_set->white_list;
-       struct maclist *black_maclist = (struct maclist *)&mac_list_set->black_list;
-       int mac_mode = mac_list_set->mode;
-       int length;
-       int i;
-
-       ap_macmode = mac_mode;
-       if (mac_mode == MACLIST_MODE_DISABLED) {
-               
-               bzero(&ap_black_list, sizeof(struct mflist));
-
-               
-               dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
-       } else {
-               scb_val_t scbval;
-               char mac_buf[256] = {0};
-               struct maclist *assoc_maclist = (struct maclist *) mac_buf;
-
-               mac_mode = MACLIST_MODE_ALLOW;
-               
-               dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode));
-
-               
-               length = sizeof(white_maclist->count)+white_maclist->count*ETHER_ADDR_LEN;
-               dev_wlc_ioctl(dev, WLC_SET_MACLIST, white_maclist, length);
-               WL_SOFTAP(("White List, length %d:\n", length));
-               for (i = 0; i < white_maclist->count; i++)
-                       WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
-                               i, white_maclist->ea[i].octet[0], white_maclist->ea[i].octet[1], \
-                               white_maclist->ea[i].octet[2], \
-                               white_maclist->ea[i].octet[3], white_maclist->ea[i].octet[4], \
-                               white_maclist->ea[i].octet[5]));
-
-               
-               bcopy(black_maclist, &ap_black_list, sizeof(ap_black_list));
-
-               WL_SOFTAP(("Black List, size %d:\n", sizeof(ap_black_list)));
-               for (i = 0; i < ap_black_list.count; i++)
-                       WL_SOFTAP(("mac %d: %02X:%02X:%02X:%02X:%02X:%02X\n",
-                               i, ap_black_list.ea[i].octet[0], ap_black_list.ea[i].octet[1], \
-                               ap_black_list.ea[i].octet[2], \
-                               ap_black_list.ea[i].octet[3], \
-                               ap_black_list.ea[i].octet[4], ap_black_list.ea[i].octet[5]));
-
-               
-               dev_wlc_ioctl(dev, WLC_GET_ASSOCLIST, assoc_maclist, 256);
-               if (assoc_maclist->count) {
-                       int j;
-                       for (i = 0; i < assoc_maclist->count; i++) {
-                               for (j = 0; j < white_maclist->count; j++) {
-                                       if (!bcmp(&assoc_maclist->ea[i], &white_maclist->ea[j], \
-                                               ETHER_ADDR_LEN)) {
-                                               WL_SOFTAP(("match allow, let it be\n"));
-                                               break;
-                                       }
-                               }
-                               if (j == white_maclist->count) {
-                                               WL_SOFTAP(("match black, deauth it\n"));
-                                               scbval.val = htod32(1);
-                                               bcopy(&assoc_maclist->ea[i], &scbval.ea, \
-                                               ETHER_ADDR_LEN);
-                                               dev_wlc_ioctl(dev, \
-                                                       WLC_SCB_DEAUTHENTICATE_FOR_REASON, &scbval,
-                                                       sizeof(scb_val_t));
-                               }
-                       }
-               }
-       }
-       return 0;
-}
-#endif /* SOFTAP */
-
-
-#ifdef SOFTAP
-int set_macfilt_from_string(struct mflist *pmflist, char **param_str)
-{
-       return 0;
-}
-#endif
-
-
-#ifdef SOFTAP
-#define PARAM_OFFSET PROFILE_OFFSET
-
-int wl_iw_process_private_ascii_cmd(
-                       struct net_device *dev,
-                       struct iw_request_info *info,
-                       union iwreq_data *dwrq,
-                       char *cmd_str)
-{
-       int ret = 0;
-       char *sub_cmd = cmd_str + PROFILE_OFFSET + strlen("ASCII_CMD=");
-
-       WL_SOFTAP(("\n %s: ASCII_CMD: offs_0:%s, offset_32:\n'%s'\n",
-               __FUNCTION__, cmd_str, cmd_str + PROFILE_OFFSET));
-
-       if (strnicmp(sub_cmd, "AP_CFG", strlen("AP_CFG")) == 0) {
-
-               WL_SOFTAP((" AP_CFG \n"));
-
-               
-               if (init_ap_profile_from_string(cmd_str+PROFILE_OFFSET, &my_ap) != 0) {
-                               WL_ERROR(("ERROR: SoftAP CFG prams !\n"));
-                               ret = -1;
-               } else {
-                       ret = set_ap_cfg(dev, &my_ap);
-               }
-
-       } else if (strnicmp(sub_cmd, "AP_BSS_START", strlen("AP_BSS_START")) == 0) {
-
-               WL_SOFTAP(("\n SOFTAP - ENABLE BSS \n"));
-
-               
-               WL_SOFTAP(("\n!!! got 'WL_AP_EN_BSS' from WPA supplicant, dev:%s\n", dev->name));
-
-#ifndef AP_ONLY
-               if (ap_net_dev == NULL) {
-                                printf("\n ERROR: SOFTAP net_dev* is NULL !!!\n");
-               } else {
-                         
-                       if ((ret = iwpriv_en_ap_bss(ap_net_dev, info, dwrq, cmd_str)) < 0)
-                               WL_ERROR(("%s line %d fail to set bss up\n", \
-                                       __FUNCTION__, __LINE__));
-               }
-#else
-               if ((ret = iwpriv_en_ap_bss(dev, info, dwrq, cmd_str)) < 0)
-                               WL_ERROR(("%s line %d fail to set bss up\n", \
-                                       __FUNCTION__, __LINE__));
-#endif
-       } else if (strnicmp(sub_cmd, "ASSOC_LST", strlen("ASSOC_LST")) == 0) {
-
-               
-
-       } else if (strnicmp(sub_cmd, "AP_BSS_STOP", strlen("AP_BSS_STOP")) == 0) {
-
-               WL_SOFTAP((" \n temp DOWN SOFTAP\n"));
-#ifndef AP_ONLY
-               if ((ret = dev_iw_write_cfg1_bss_var(dev, 0)) < 0) {
-                               WL_ERROR(("%s line %d fail to set bss down\n", \
-                                       __FUNCTION__, __LINE__));
-               }
-#endif
-       }
-
-       return ret;
-
-}
-#endif 
-static int wl_iw_set_priv(
-       struct net_device *dev,
-       struct iw_request_info *info,
-       struct iw_point *dwrq,
-       char *ext
-)
-{
-       int ret = 0;
-       char * extra;
-
-       wl_iw_t *iw = *(wl_iw_t **)netdev_priv(dev);
-       if (!(extra = kmalloc(dwrq->length, GFP_KERNEL)))
-           return -ENOMEM;
-
-       if (copy_from_user(extra, dwrq->pointer, dwrq->length)) {
-           kfree(extra);
-           return -EFAULT;
-       }
-
-       WL_TRACE(("%s: SIOCSIWPRIV request %s, info->cmd:%x, info->flags:%d\n dwrq->length:%d\n",
-               dev->name, extra, info->cmd, info->flags, dwrq->length));
-
-       
-       if (dwrq->length && extra) {
-               WAKE_LOCK_INIT(iw->pub, WAKE_LOCK_PRIV, "wl_iw_set_priv");
-               WAKE_LOCK(iw->pub, WAKE_LOCK_PRIV);
-
-               if (g_onoff == G_WLAN_SET_OFF) {
-                       if (strnicmp(extra, "START", strlen("START")) != 0) {
-                                       WL_ERROR(("%s First IOCTL after stop is NOT START \n", \
-                                                               __FUNCTION__));
-                               WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
-                               WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
-                               kfree(extra);
-                               return -EFAULT;
-                       } else {
-                               wl_iw_control_wl_on(dev, info);
-                               WL_TRACE(("%s, Received regular START command\n", __FUNCTION__));
-                       }
-               }
-
-           if (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
-#ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
-                       WL_TRACE(("%s: active scan setting suppressed\n", dev->name));
-#else
-                       ret = wl_iw_set_active_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif 
-           }
-           else if (strnicmp(extra, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0)
-#ifdef ENABLE_ACTIVE_PASSIVE_SCAN_SUPPRESS
-                       WL_TRACE(("%s: passive scan setting suppressed\n", dev->name));
-#else
-                       ret = wl_iw_set_passive_scan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif 
-           else if (strnicmp(extra, "RSSI", strlen("RSSI")) == 0)
-                       ret = wl_iw_get_rssi(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "LINKSPEED", strlen("LINKSPEED")) == 0)
-                       ret = wl_iw_get_link_speed(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "MACADDR", strlen("MACADDR")) == 0)
-                       ret = wl_iw_get_macaddr(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "COUNTRY", strlen("COUNTRY")) == 0)
-                       ret = wl_iw_set_country(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "STOP", strlen("STOP")) == 0)
-                       ret = wl_iw_control_wl_off(dev, info);
-           else if (strnicmp(extra, BAND_GET_CMD, strlen(BAND_GET_CMD)) == 0)
-                       ret = wl_iw_get_band(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, BAND_SET_CMD, strlen(BAND_SET_CMD)) == 0)
-                       ret = wl_iw_set_band(dev, info, (union iwreq_data *)dwrq, extra);
-#if defined(CSCAN)
-           
-           else if (strnicmp(extra, CSCAN_COMMAND, strlen(CSCAN_COMMAND)) == 0)
-                       ret = wl_iw_set_cscan(dev, info, (union iwreq_data *)dwrq, extra);
-#endif 
-#ifdef CUSTOMER_HW2
-           else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
-                       ret = wl_iw_set_power_mode(dev, info, (union iwreq_data *)dwrq, extra);
-           else if (strnicmp(extra, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0)
-                       ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
-#else
-           else if (strnicmp(extra, "POWERMODE", strlen("POWERMODE")) == 0)
-                       ret = wl_iw_set_btcoex_dhcp(dev, info, (union iwreq_data *)dwrq, extra);
-#endif
-#ifdef SOFTAP
-           else if (strnicmp(extra, "ASCII_CMD", strlen("ASCII_CMD")) == 0) {
-               
-                   wl_iw_process_private_ascii_cmd(dev, info, (union iwreq_data *)dwrq, extra);
-           }
-               else if (strnicmp(extra, "AP_MAC_LIST_SET", strlen("AP_MAC_LIST_SET")) == 0) {
-                       WL_SOFTAP(("penguin, set AP_MAC_LIST_SET\n"));
-                       set_ap_mac_list(dev, (extra + PROFILE_OFFSET));
-           }
-#endif 
-           else {
-                       WL_TRACE(("Unkown PRIVATE command %s\n", extra));
-                       snprintf(extra, MAX_WX_STRING, "OK");
-                       dwrq->length = strlen("OK") + 1;
-               }
-               WAKE_UNLOCK(iw->pub, WAKE_LOCK_PRIV);
-               WAKE_LOCK_DESTROY(iw->pub, WAKE_LOCK_PRIV);
-       }
-
-       if (extra) {
-           if (copy_to_user(dwrq->pointer, extra, dwrq->length)) {
-                       kfree(extra);
-                       return -EFAULT;
-           }
-
-           kfree(extra);
-       }
-
-       return ret;
-}
-
-static const iw_handler wl_iw_handler[] =
-{
-       (iw_handler) wl_iw_config_commit,       
-       (iw_handler) wl_iw_get_name,            
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_set_freq,            
-       (iw_handler) wl_iw_get_freq,            
-       (iw_handler) wl_iw_set_mode,            
-       (iw_handler) wl_iw_get_mode,            
-       (iw_handler) wl_iw_set_sens,
-       (iw_handler) wl_iw_get_sens,
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_get_range,           
-       (iw_handler) wl_iw_set_priv,            
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_set_spy,             
-       (iw_handler) wl_iw_get_spy,             
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_set_wap,             
-       (iw_handler) wl_iw_get_wap,             
-#if WIRELESS_EXT > 17
-       (iw_handler) wl_iw_mlme,                
-#else
-       (iw_handler) NULL,                      
-#endif
-#if defined(WL_IW_USE_ISCAN)
-       (iw_handler) wl_iw_iscan_get_aplist,    
-#else
-       (iw_handler) wl_iw_get_aplist,          
-#endif 
-#if WIRELESS_EXT > 13
-#if defined(WL_IW_USE_ISCAN)
-       (iw_handler) wl_iw_iscan_set_scan,      
-       (iw_handler) wl_iw_iscan_get_scan,      
-#else
-       (iw_handler) wl_iw_set_scan,            
-       (iw_handler) wl_iw_get_scan,            
-#endif
-#else  
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-#endif 
-       (iw_handler) wl_iw_set_essid,           
-       (iw_handler) wl_iw_get_essid,           
-       (iw_handler) wl_iw_set_nick,            
-       (iw_handler) wl_iw_get_nick,            
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_set_rate,            
-       (iw_handler) wl_iw_get_rate,            
-       (iw_handler) wl_iw_set_rts,             
-       (iw_handler) wl_iw_get_rts,             
-       (iw_handler) wl_iw_set_frag,            
-       (iw_handler) wl_iw_get_frag,            
-       (iw_handler) wl_iw_set_txpow,           
-       (iw_handler) wl_iw_get_txpow,           
-#if WIRELESS_EXT > 10
-       (iw_handler) wl_iw_set_retry,           
-       (iw_handler) wl_iw_get_retry,           
-#endif 
-       (iw_handler) wl_iw_set_encode,          
-       (iw_handler) wl_iw_get_encode,          
-       (iw_handler) wl_iw_set_power,           
-       (iw_handler) wl_iw_get_power,           
-#if WIRELESS_EXT > 17
-       (iw_handler) NULL,                      
-       (iw_handler) NULL,                      
-       (iw_handler) wl_iw_set_wpaie,           
-       (iw_handler) wl_iw_get_wpaie,           
-       (iw_handler) wl_iw_set_wpaauth,         
-       (iw_handler) wl_iw_get_wpaauth,         
-       (iw_handler) wl_iw_set_encodeext,       
-       (iw_handler) wl_iw_get_encodeext,       
-#ifdef BCMWPA2
-       (iw_handler) wl_iw_set_pmksa,                   
-#endif
-#endif 
-};
-
-#if WIRELESS_EXT > 12
-static const iw_handler wl_iw_priv_handler[] = {
-       NULL,
-       (iw_handler)wl_iw_set_active_scan,
-       NULL,
-       (iw_handler)wl_iw_get_rssi,
-       NULL,
-       (iw_handler)wl_iw_set_passive_scan,
-       NULL,
-       (iw_handler)wl_iw_get_link_speed,
-       NULL,
-       (iw_handler)wl_iw_get_macaddr,
-       NULL,
-       (iw_handler)wl_iw_control_wl_off,
-       NULL,
-       (iw_handler)wl_iw_control_wl_on,
-#ifdef SOFTAP       
-
-       
-       NULL,
-       (iw_handler)iwpriv_set_ap_config,
-
-       
-       
-       NULL,
-       (iw_handler)iwpriv_get_assoc_list,
-
-       
-       NULL,
-       (iw_handler)iwpriv_set_mac_filters,
-
-       
-       NULL,
-       (iw_handler)iwpriv_en_ap_bss,
-
-       
-       NULL,
-       (iw_handler)iwpriv_wpasupp_loop_tst,
-       
-       NULL,
-       (iw_handler)iwpriv_softap_stop,
-       
-       NULL,
-       (iw_handler)iwpriv_fw_reload,
-#endif 
-#if defined(CSCAN)
-       
-       NULL,
-       (iw_handler)iwpriv_set_cscan
-#endif         
-};
-
-static const struct iw_priv_args wl_iw_priv_args[] =
-{
-       {       
-               WL_IW_SET_ACTIVE_SCAN,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "SCAN-ACTIVE"
-       },
-       {
-               WL_IW_GET_RSSI,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "RSSI"
-       },
-       {
-               WL_IW_SET_PASSIVE_SCAN,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "SCAN-PASSIVE"
-       },
-       {
-               WL_IW_GET_LINK_SPEED,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "LINKSPEED"
-       },
-       {
-               WL_IW_GET_CURR_MACADDR,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "Macaddr"
-       },
-       {
-               WL_IW_SET_STOP,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "STOP"
-       },
-       {
-               WL_IW_SET_START,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "START"
-       },
-
-#ifdef SOFTAP
-       
-       
-       {
-               WL_SET_AP_CFG,
-               IW_PRIV_TYPE_CHAR |  256,      
-               0,
-               "AP_SET_CFG"
-       },
-
-       {
-               WL_AP_STA_LIST,
-               0,                     
-               IW_PRIV_TYPE_CHAR | 0, 
-               "AP_GET_STA_LIST"
-       },
-
-       {
-               WL_AP_MAC_FLTR,
-               IW_PRIV_TYPE_CHAR | 256,                      
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,    
-               "AP_SET_MAC_FLTR"
-       },
-
-       { 
-               WL_AP_BSS_START,
-               0,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING,
-               "AP_BSS_START"
-       },
-
-       {
-               AP_LPB_CMD,
-               IW_PRIV_TYPE_CHAR | 256,   
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,    
-               "AP_LPB_CMD"
-       },
-
-       { 
-               WL_AP_STOP,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,   
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,   
-               "AP_BSS_STOP"
-       },
-       { 
-               WL_FW_RELOAD,
-               IW_PRIV_TYPE_CHAR | 256,
-               IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 0,
-               "WL_FW_RELOAD"
-       },
-#endif 
-#if defined(CSCAN)
-       { 
-               WL_COMBO_SCAN,
-               IW_PRIV_TYPE_CHAR | 1024,  
-               0,
-               "CSCAN"
-       },
-#endif 
-       };
-
-const struct iw_handler_def wl_iw_handler_def =
-{
-       .num_standard = ARRAYSIZE(wl_iw_handler),
-       .standard = (iw_handler *) wl_iw_handler,
-       .num_private = ARRAYSIZE(wl_iw_priv_handler),
-       .num_private_args = ARRAY_SIZE(wl_iw_priv_args),
-       .private = (iw_handler *)wl_iw_priv_handler,
-       .private_args = (void *) wl_iw_priv_args,
-
-#if WIRELESS_EXT >= 19
-       get_wireless_stats: dhd_get_wireless_stats,
-#endif 
-       };
-#endif 
-
-
-
-int wl_iw_ioctl(
-       struct net_device *dev,
-       struct ifreq *rq,
-       int cmd
-)
-{
-       struct iwreq *wrq = (struct iwreq *) rq;
-       struct iw_request_info info;
-       iw_handler handler;
-       char *extra = NULL;
-       int token_size = 1, max_tokens = 0, ret = 0;
-
-       WL_TRACE(("\n%s, cmd:%x alled via dhd->do_ioctl()entry point\n", __FUNCTION__, cmd));
-       if (cmd < SIOCIWFIRST ||
-               IW_IOCTL_IDX(cmd) >= ARRAYSIZE(wl_iw_handler) ||
-               !(handler = wl_iw_handler[IW_IOCTL_IDX(cmd)])) {
-                       WL_ERROR(("%s: error in cmd=%x : not supported\n", __FUNCTION__, cmd));
-                       return -EOPNOTSUPP;
-       }
-
-       switch (cmd) {
-
-       case SIOCSIWESSID:
-       case SIOCGIWESSID:
-       case SIOCSIWNICKN:
-       case SIOCGIWNICKN:
-               max_tokens = IW_ESSID_MAX_SIZE + 1;
-               break;
-
-       case SIOCSIWENCODE:
-       case SIOCGIWENCODE:
-#if WIRELESS_EXT > 17
-       case SIOCSIWENCODEEXT:
-       case SIOCGIWENCODEEXT:
-#endif
-               max_tokens = wrq->u.data.length;
-               break;
-
-       case SIOCGIWRANGE:
-               
-               max_tokens = sizeof(struct iw_range) + 500;
-               break;
-
-       case SIOCGIWAPLIST:
-               token_size = sizeof(struct sockaddr) + sizeof(struct iw_quality);
-               max_tokens = IW_MAX_AP;
-               break;
-
-#if WIRELESS_EXT > 13
-       case SIOCGIWSCAN:
-#if defined(WL_IW_USE_ISCAN)
-       if (g_iscan)
-               max_tokens = wrq->u.data.length;
-       else
-#endif
-               max_tokens = IW_SCAN_MAX_DATA;
-               break;
-#endif 
-
-       case SIOCSIWSPY:
-               token_size = sizeof(struct sockaddr);
-               max_tokens = IW_MAX_SPY;
-               break;
-
-       case SIOCGIWSPY:
-               token_size = sizeof(struct sockaddr) + sizeof(struct iw_quality);
-               max_tokens = IW_MAX_SPY;
-               break;
-
-#if WIRELESS_EXT > 17
-       case SIOCSIWPMKSA:
-       case SIOCSIWGENIE:
-#endif 
-       case SIOCSIWPRIV:
-               max_tokens = wrq->u.data.length;
-               break;
-       }
-
-       if (max_tokens && wrq->u.data.pointer) {
-               if (wrq->u.data.length > max_tokens) {
-                       WL_ERROR(("%s: error in cmd=%x wrq->u.data.length=%d  > max_tokens=%d\n", \
-                               __FUNCTION__, cmd, wrq->u.data.length, max_tokens));
-                       return -E2BIG;
-               }
-               if (!(extra = kmalloc(max_tokens * token_size, GFP_KERNEL)))
-                       return -ENOMEM;
-
-               if (copy_from_user(extra, wrq->u.data.pointer, wrq->u.data.length * token_size)) {
-                       kfree(extra);
-                       return -EFAULT;
-               }
-       }
-
-       info.cmd = cmd;
-       info.flags = 0;
-
-       ret = handler(dev, &info, &wrq->u, extra);
-
-       if (extra) {
-               if (copy_to_user(wrq->u.data.pointer, extra, wrq->u.data.length * token_size)) {
-                       kfree(extra);
-                       return -EFAULT;
-               }
-
-               kfree(extra);
-       }
-
-       return ret;
-}
-
-
-bool
-wl_iw_conn_status_str(uint32 event_type, uint32 status, uint32 reason,
-       char* stringBuf, uint buflen)
-{
-       typedef struct conn_fail_event_map_t {
-               uint32 inEvent;                 
-               uint32 inStatus;                
-               uint32 inReason;                
-               const char* outName;    
-               const char* outCause;   
-       } conn_fail_event_map_t;
-
-       
-#      define WL_IW_DONT_CARE  9999
-       const conn_fail_event_map_t event_map [] = {
-               
-               
-               {WLC_E_SET_SSID,     WLC_E_STATUS_SUCCESS,   WL_IW_DONT_CARE,
-               "Conn", "Success"},
-               {WLC_E_SET_SSID,     WLC_E_STATUS_NO_NETWORKS, WL_IW_DONT_CARE,
-               "Conn", "NoNetworks"},
-               {WLC_E_SET_SSID,     WLC_E_STATUS_FAIL,      WL_IW_DONT_CARE,
-               "Conn", "ConfigMismatch"},
-               {WLC_E_PRUNE,        WL_IW_DONT_CARE,        WLC_E_PRUNE_ENCR_MISMATCH,
-               "Conn", "EncrypMismatch"},
-               {WLC_E_PRUNE,        WL_IW_DONT_CARE,        WLC_E_RSN_MISMATCH,
-               "Conn", "RsnMismatch"},
-               {WLC_E_AUTH,         WLC_E_STATUS_TIMEOUT,   WL_IW_DONT_CARE,
-               "Conn", "AuthTimeout"},
-               {WLC_E_AUTH,         WLC_E_STATUS_FAIL,      WL_IW_DONT_CARE,
-               "Conn", "AuthFail"},
-               {WLC_E_AUTH,         WLC_E_STATUS_NO_ACK,    WL_IW_DONT_CARE,
-               "Conn", "AuthNoAck"},
-               {WLC_E_REASSOC,      WLC_E_STATUS_FAIL,      WL_IW_DONT_CARE,
-               "Conn", "ReassocFail"},
-               {WLC_E_REASSOC,      WLC_E_STATUS_TIMEOUT,   WL_IW_DONT_CARE,
-               "Conn", "ReassocTimeout"},
-               {WLC_E_REASSOC,      WLC_E_STATUS_ABORT,     WL_IW_DONT_CARE,
-               "Conn", "ReassocAbort"},
-               {WLC_E_PSK_SUP,      WLC_SUP_KEYED,          WL_IW_DONT_CARE,
-               "Sup", "ConnSuccess"},
-               {WLC_E_PSK_SUP,      WL_IW_DONT_CARE,        WL_IW_DONT_CARE,
-               "Sup", "WpaHandshakeFail"},
-               {WLC_E_DEAUTH_IND,   WL_IW_DONT_CARE,        WL_IW_DONT_CARE,
-               "Conn", "Deauth"},
-               {WLC_E_DISASSOC_IND, WL_IW_DONT_CARE,        WL_IW_DONT_CARE,
-               "Conn", "DisassocInd"},
-               {WLC_E_DISASSOC,     WL_IW_DONT_CARE,        WL_IW_DONT_CARE,
-               "Conn", "Disassoc"}
-       };
-
-       const char* name = "";
-       const char* cause = NULL;
-       int i;
-
-       
-       for (i = 0;  i < sizeof(event_map)/sizeof(event_map[0]);  i++) {
-               const conn_fail_event_map_t* row = &event_map[i];
-               if (row->inEvent == event_type &&
-                   (row->inStatus == status || row->inStatus == WL_IW_DONT_CARE) &&
-                   (row->inReason == reason || row->inReason == WL_IW_DONT_CARE)) {
-                       name = row->outName;
-                       cause = row->outCause;
-                       break;
-               }
-       }
-
-       
-       if (cause) {
-               memset(stringBuf, 0, buflen);
-               snprintf(stringBuf, buflen, "%s %s %02d %02d",
-                       name, cause, status, reason);
-               WL_INFORM(("Connection status: %s\n", stringBuf));
-               return TRUE;
-       } else {
-               return FALSE;
-       }
-}
-
-#if WIRELESS_EXT > 14
-
-static bool
-wl_iw_check_conn_fail(wl_event_msg_t *e, char* stringBuf, uint buflen)
-{
-       uint32 event = ntoh32(e->event_type);
-       uint32 status =  ntoh32(e->status);
-       uint32 reason =  ntoh32(e->reason);
-
-       if (wl_iw_conn_status_str(event, status, reason, stringBuf, buflen)) {
-               return TRUE;
-       }
-       else
-               return FALSE;
-}
-#endif 
-
-#ifndef IW_CUSTOM_MAX
-#define IW_CUSTOM_MAX 256 
-#endif 
-
-void
-wl_iw_event(struct net_device *dev, wl_event_msg_t *e, void* data)
-{
-#if WIRELESS_EXT > 13
-       union iwreq_data wrqu;
-       char extra[IW_CUSTOM_MAX + 1];
-       int cmd = 0;
-       uint32 event_type = ntoh32(e->event_type);
-       uint16 flags =  ntoh16(e->flags);
-       uint32 datalen = ntoh32(e->datalen);
-       uint32 status =  ntoh32(e->status);
-       wl_iw_t *iw;
-       uint32 toto;
-
-       memset(&wrqu, 0, sizeof(wrqu));
-       memset(extra, 0, sizeof(extra));
-       iw = 0;
-
-       if (!dev) {
-               WL_ERROR(("%s: dev is null\n", __FUNCTION__));
-               return;
-       }
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-
-       //WL_TRACE(("%s: dev=%s event=%d \n", __FUNCTION__, dev->name, event_type));
-
-       
-       switch (event_type) {
-#if defined(SOFTAP)
-       case WLC_E_PRUNE:
-               if (ap_cfg_running) {
-                       char *macaddr = (char *)&e->addr;
-                       WL_SOFTAP(("PRUNE received, %02X:%02X:%02X:%02X:%02X:%02X!\n",
-                               macaddr[0], macaddr[1], macaddr[2], macaddr[3], \
-                               macaddr[4], macaddr[5]));
-
-                       
-                       if (ap_macmode)
-                       {
-                               int i;
-                               for (i = 0; i < ap_black_list.count; i++) {
-                                       if (!bcmp(macaddr, &ap_black_list.ea[i], \
-                                               sizeof(struct ether_addr))) {
-                                               WL_SOFTAP(("mac in black list, ignore it\n"));
-                                               break;
-                                       }
-                               }
-
-                               if (i == ap_black_list.count) {
-                                       
-                                       char mac_buf[32] = {0};
-                                       sprintf(mac_buf, "STA_BLOCK %02X:%02X:%02X:%02X:%02X:%02X",
-                                               macaddr[0], macaddr[1], macaddr[2],
-                                               macaddr[3], macaddr[4], macaddr[5]);
-                                       wl_iw_send_priv_event(priv_dev, mac_buf);
-                               }
-                       }
-               }
-               break;
-#endif 
-       case WLC_E_TXFAIL:
-               cmd = IWEVTXDROP;
-               memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
-               wrqu.addr.sa_family = ARPHRD_ETHER;
-               break;
-#if WIRELESS_EXT > 14
-       case WLC_E_JOIN:
-       case WLC_E_ASSOC_IND:
-       case WLC_E_REASSOC_IND:
-#if defined(SOFTAP)
-               WL_SOFTAP(("STA connect received %d\n", event_type));
-               if (ap_cfg_running) {
-                       wl_iw_send_priv_event(priv_dev, "STA_JOIN");
-                       return;
-               }
-#endif 
-               memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
-               wrqu.addr.sa_family = ARPHRD_ETHER;
-               cmd = IWEVREGISTERED;
-               break;
-       case WLC_E_DEAUTH_IND:
-       case WLC_E_DISASSOC_IND:
-#if defined(SOFTAP)
-               WL_SOFTAP(("STA disconnect received %d\n", event_type));
-               if (ap_cfg_running) {
-                       wl_iw_send_priv_event(priv_dev, "STA_LEAVE");
-                       return;
-               }
-#endif 
-               cmd = SIOCGIWAP;
-               bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
-               wrqu.addr.sa_family = ARPHRD_ETHER;
-               bzero(&extra, ETHER_ADDR_LEN);
-               break;
-       case WLC_E_LINK:
-       case WLC_E_NDIS_LINK:
-               cmd = SIOCGIWAP;
-               if (!(flags & WLC_EVENT_MSG_LINK)) {
-                       
-                       
-#ifdef SOFTAP
-#ifdef AP_ONLY
-               if (ap_cfg_running) {
-#else
-               if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
-#endif 
-                       
-                       WL_SOFTAP(("AP DOWN %d\n", event_type));
-                       wl_iw_send_priv_event(priv_dev, "AP_DOWN");
-               } else {
-                       WL_TRACE(("STA_Link Down\n"));
-                       g_ss_cache_ctrl.m_link_down = 1;
-               }
-#else          
-               g_ss_cache_ctrl.m_link_down = 1;
-#endif 
-                       WL_TRACE(("Link Down\n"));
-
-                       bzero(wrqu.addr.sa_data, ETHER_ADDR_LEN);
-                       bzero(&extra, ETHER_ADDR_LEN);
-                       WAKE_LOCK_TIMEOUT(iw->pub, WAKE_LOCK_LINK_DOWN_TMOUT, 20 * HZ);
-               }
-               else {
-                       
-                       memcpy(wrqu.addr.sa_data, &e->addr, ETHER_ADDR_LEN);
-                       g_ss_cache_ctrl.m_link_down = 0;
-                       
-                       memcpy(g_ss_cache_ctrl.m_active_bssid, &e->addr, ETHER_ADDR_LEN);
-#ifdef SOFTAP
-
-#ifdef AP_ONLY
-                       if (ap_cfg_running) {
-#else
-                       if (ap_cfg_running && !strncmp(dev->name, "wl0.1", 5)) {
-#endif
-                       
-                               WL_SOFTAP(("AP UP %d\n", event_type));
-                               wl_iw_send_priv_event(priv_dev, "AP_UP");
-                       } else {
-                               WL_TRACE(("STA_LINK_UP\n"));
-                       }
-#else
-#endif 
-                       WL_TRACE(("Link UP\n"));
-
-               }
-               wrqu.addr.sa_family = ARPHRD_ETHER;
-               break;
-       case WLC_E_ACTION_FRAME:
-               cmd = IWEVCUSTOM;
-               if (datalen + 1 <= sizeof(extra)) {
-                       wrqu.data.length = datalen + 1;
-                       extra[0] = WLC_E_ACTION_FRAME;
-                       memcpy(&extra[1], data, datalen);
-                       WL_TRACE(("WLC_E_ACTION_FRAME len %d \n", wrqu.data.length));
-               }
-               break;
-
-       case WLC_E_ACTION_FRAME_COMPLETE:
-               cmd = IWEVCUSTOM;
-               memcpy(&toto, data, 4);
-               if (sizeof(status) + 1 <= sizeof(extra)) {
-                       wrqu.data.length = sizeof(status) + 1;
-                       extra[0] = WLC_E_ACTION_FRAME_COMPLETE;
-                       memcpy(&extra[1], &status, sizeof(status));
-                       printf("wl_iw_event status %d PacketId %d \n", status, toto);
-                       printf("WLC_E_ACTION_FRAME_COMPLETE len %d \n", wrqu.data.length);
-               }
-               break;
-#endif 
-#if WIRELESS_EXT > 17
-       case WLC_E_MIC_ERROR: {
-               struct  iw_michaelmicfailure  *micerrevt = (struct  iw_michaelmicfailure  *)&extra;
-               cmd = IWEVMICHAELMICFAILURE;
-               wrqu.data.length = sizeof(struct iw_michaelmicfailure);
-               if (flags & WLC_EVENT_MSG_GROUP)
-                       micerrevt->flags |= IW_MICFAILURE_GROUP;
-               else
-                       micerrevt->flags |= IW_MICFAILURE_PAIRWISE;
-               memcpy(micerrevt->src_addr.sa_data, &e->addr, ETHER_ADDR_LEN);
-               micerrevt->src_addr.sa_family = ARPHRD_ETHER;
-
-               break;
-       }
-#ifdef BCMWPA2
-       case WLC_E_PMKID_CACHE: {
-               if (data)
-               {
-                       struct iw_pmkid_cand *iwpmkidcand = (struct iw_pmkid_cand *)&extra;
-                       pmkid_cand_list_t *pmkcandlist;
-                       pmkid_cand_t    *pmkidcand;
-                       int count;
-
-                       cmd = IWEVPMKIDCAND;
-                       pmkcandlist = data;
-                       count = ntoh32_ua((uint8 *)&pmkcandlist->npmkid_cand);
-                       ASSERT(count >= 0);
-                       wrqu.data.length = sizeof(struct iw_pmkid_cand);
-                       pmkidcand = pmkcandlist->pmkid_cand;
-                       while (count) {
-                               bzero(iwpmkidcand, sizeof(struct iw_pmkid_cand));
-                               if (pmkidcand->preauth)
-                                       iwpmkidcand->flags |= IW_PMKID_CAND_PREAUTH;
-                               bcopy(&pmkidcand->BSSID, &iwpmkidcand->bssid.sa_data,
-                                       ETHER_ADDR_LEN);
-#ifndef SANDGATE2G
-                               wireless_send_event(dev, cmd, &wrqu, extra);
-#endif
-                               pmkidcand++;
-                               count--;
-                       }
-               }
-               return;
-       }
-#endif 
-#endif 
-
-       case WLC_E_SCAN_COMPLETE:
-#if defined(WL_IW_USE_ISCAN)
-               if ((g_iscan) && (g_iscan->sysioc_pid >= 0) &&
-                       (g_iscan->iscan_state != ISCAN_STATE_IDLE))
-               {
-                       up(&g_iscan->sysioc_sem);
-               } else {
-                       cmd = SIOCGIWSCAN;
-                       wrqu.data.length = strlen(extra);
-                       WL_TRACE(("Event WLC_E_SCAN_COMPLETE from specific scan %d\n", \
-                               g_iscan->iscan_state));
-               }
-#else
-               cmd = SIOCGIWSCAN;
-               wrqu.data.length = strlen(extra);
-               WL_TRACE(("Event WLC_E_SCAN_COMPLETE\n"));
-#endif 
-       break;
-
-       default:
-               
-               WL_TRACE(("Unknown Event %d: ignoring\n", event_type));
-               break;
-       }
-#ifndef SANDGATE2G
-               if (cmd) {
-                       if (cmd == SIOCGIWSCAN)
-                               wireless_send_event(dev, cmd, &wrqu, NULL);
-                       else
-                               wireless_send_event(dev, cmd, &wrqu, extra);
-               }
-#endif
-
-#if WIRELESS_EXT > 14
-       
-       memset(extra, 0, sizeof(extra));
-       if (wl_iw_check_conn_fail(e, extra, sizeof(extra))) {
-               cmd = IWEVCUSTOM;
-               wrqu.data.length = strlen(extra);
-#ifndef SANDGATE2G
-               wireless_send_event(dev, cmd, &wrqu, extra);
-#endif
-       }
-#endif 
-
-#endif 
-}
-
-int wl_iw_get_wireless_stats(struct net_device *dev, struct iw_statistics *wstats)
-{
-       int res = 0;
-       wl_cnt_t cnt;
-       int phy_noise;
-       int rssi;
-       scb_val_t scb_val;
-
-       phy_noise = 0;
-       if ((res = dev_wlc_ioctl(dev, WLC_GET_PHY_NOISE, &phy_noise, sizeof(phy_noise))))
-               goto done;
-
-       phy_noise = dtoh32(phy_noise);
-       WL_TRACE(("wl_iw_get_wireless_stats phy noise=%d\n", phy_noise));
-
-       bzero(&scb_val, sizeof(scb_val_t));
-       if ((res = dev_wlc_ioctl(dev, WLC_GET_RSSI, &scb_val, sizeof(scb_val_t))))
-               goto done;
-
-       rssi = dtoh32(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=%d\n", (int)sizeof(wl_cnt_t)));
-
-       memset(&cnt, 0, sizeof(wl_cnt_t));
-       res = dev_wlc_bufvar_get(dev, "counters", (char *)&cnt, sizeof(wl_cnt_t));
-       if (res)
-       {
-               WL_ERROR(("wl_iw_get_wireless_stats counters failed error=%d\n", res));
-               goto done;
-       }
-
-       cnt.version = dtoh16(cnt.version);
-       if (cnt.version != WL_CNT_T_VERSION) {
-               WL_TRACE(("\tIncorrect version of counters struct: expected %d; got %d\n",
-                       WL_CNT_T_VERSION, cnt.version));
-               goto done;
-       }
-
-       wstats->discard.nwid = 0;
-       wstats->discard.code = dtoh32(cnt.rxundec);
-       wstats->discard.fragment = dtoh32(cnt.rxfragerr);
-       wstats->discard.retries = dtoh32(cnt.txfail);
-       wstats->discard.misc = dtoh32(cnt.rxrunt) + dtoh32(cnt.rxgiant);
-       wstats->miss.beacon = 0;
-
-       WL_TRACE(("wl_iw_get_wireless_stats counters txframe=%d txbyte=%d\n",
-               dtoh32(cnt.txframe), dtoh32(cnt.txbyte)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters rxfrmtoolong=%d\n", dtoh32(cnt.rxfrmtoolong)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters rxbadplcp=%d\n", dtoh32(cnt.rxbadplcp)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters rxundec=%d\n", dtoh32(cnt.rxundec)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters rxfragerr=%d\n", dtoh32(cnt.rxfragerr)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters txfail=%d\n", dtoh32(cnt.txfail)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters rxrunt=%d\n", dtoh32(cnt.rxrunt)));
-       WL_TRACE(("wl_iw_get_wireless_stats counters rxgiant=%d\n", dtoh32(cnt.rxgiant)));
-
-#endif 
-
-done:
-       return res;
-}
-static void
-wl_iw_bt_flag_set(
-       struct net_device *dev,
-       bool set)
-{
-       char buf_flag7_dhcp_on[8] = { 7, 00, 00, 00, 0x1, 0x0, 0x00, 0x00 };
-       char buf_flag7_default[8]   = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-       rtnl_lock();
-#endif
-
-       if (set == TRUE) {
-               
-               dev_wlc_bufvar_set(dev, "btc_flags", \
-                                       (char *)&buf_flag7_dhcp_on[0], sizeof(buf_flag7_dhcp_on));
-       }
-       else  {
-               
-               dev_wlc_bufvar_set(dev, "btc_flags", \
-                                       (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
-       }
-
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27))
-       rtnl_unlock();
-#endif
-}
-
-static void
-wl_iw_bt_timerfunc(ulong data)
-{
-       bt_info_t  *bt_local = (bt_info_t *)data;
-       bt_local->timer_on = 0;
-       WL_TRACE(("%s\n", __FUNCTION__));
-       
-       up(&bt_local->bt_sem);
-}
-
-static int
-_bt_dhcp_sysioc_thread(void *data)
-{
-       DAEMONIZE("dhcp_sysioc");
-
-       while (down_interruptible(&g_bt->bt_sem) == 0) {
-               if (g_bt->timer_on) {
-                       del_timer(&g_bt->timer);
-                       g_bt->timer_on = 0;
-               }
-
-               switch (g_bt->bt_state) {
-                       case BT_DHCP_START:
-                               
-                               g_bt->bt_state = BT_DHCP_OPPORTUNITY_WINDOW;
-                               mod_timer(&g_bt->timer, jiffies + \
-                                          BT_DHCP_OPPORTUNITY_WINDOW_TIEM*HZ/1000);
-                               g_bt->timer_on = 1;
-                               break;
-                       case BT_DHCP_OPPORTUNITY_WINDOW:
-                               
-                               WL_TRACE(("%s waiting for %d msec expired, force bt flag\n", \
-                                               __FUNCTION__, BT_DHCP_OPPORTUNITY_WINDOW_TIEM));
-                               if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, TRUE);
-                               g_bt->bt_state = BT_DHCP_FLAG_FORCE_TIMEOUT;
-                               mod_timer(&g_bt->timer, jiffies + BT_DHCP_FLAG_FORCE_TIME*HZ/1000);
-                               g_bt->timer_on = 1;
-                               break;
-                       case BT_DHCP_FLAG_FORCE_TIMEOUT:
-                               
-                               WL_TRACE(("%s waiting for %d msec expired remove bt flag\n", \
-                                               __FUNCTION__, BT_DHCP_FLAG_FORCE_TIME));
-                               
-                               if (g_bt->dev)  wl_iw_bt_flag_set(g_bt->dev, FALSE);
-                               g_bt->bt_state = BT_DHCP_IDLE;
-                               g_bt->timer_on = 0;
-                               break;
-                       default:
-                               WL_ERROR(("%s error g_status=%d !!!\n", __FUNCTION__, \
-                                         g_bt->bt_state));
-                               if (g_bt->dev) wl_iw_bt_flag_set(g_bt->dev, FALSE);
-                               g_bt->bt_state = BT_DHCP_IDLE;
-                               g_bt->timer_on = 0;
-                               break;
-                }
-       }
-
-       if (g_bt->timer_on) {
-               del_timer(&g_bt->timer);
-               g_bt->timer_on = 0;
-       }
-       complete_and_exit(&g_bt->bt_exited, 0);
-}
-
-static void
-wl_iw_bt_release(void)
-{
-       bt_info_t *bt_local = g_bt;
-
-       if (!bt_local) {
-               return;
-       }
-
-       if (bt_local->bt_pid >= 0) {
-               KILL_PROC(bt_local->bt_pid, SIGTERM);
-               wait_for_completion(&bt_local->bt_exited);
-       }
-       kfree(bt_local);
-       g_bt = NULL;
-}
-
-static int
-wl_iw_bt_init(struct net_device *dev)
-{
-       bt_info_t *bt_dhcp = NULL;
-
-       bt_dhcp = kmalloc(sizeof(bt_info_t), GFP_KERNEL);
-       if (!bt_dhcp)
-               return -ENOMEM;
-
-       memset(bt_dhcp, 0, sizeof(bt_info_t));
-       bt_dhcp->bt_pid = -1;
-       g_bt = bt_dhcp;
-       bt_dhcp->dev = dev;
-       bt_dhcp->bt_state = BT_DHCP_IDLE;
-
-       
-       bt_dhcp->timer_ms    = 10;
-       init_timer(&bt_dhcp->timer);
-       bt_dhcp->timer.data = (ulong)bt_dhcp;
-       bt_dhcp->timer.function = wl_iw_bt_timerfunc;
-
-       sema_init(&bt_dhcp->bt_sem, 0);
-       init_completion(&bt_dhcp->bt_exited);
-       bt_dhcp->bt_pid = kernel_thread(_bt_dhcp_sysioc_thread, bt_dhcp, 0);
-       if (bt_dhcp->bt_pid < 0) {
-               WL_ERROR(("Failed in %s\n", __FUNCTION__));
-               return -ENOMEM;
-       }
-
-       return 0;
-}
-
-int wl_iw_attach(struct net_device *dev, void * dhdp)
-{
-       int params_size;
-       wl_iw_t *iw;
-#if defined(WL_IW_USE_ISCAN)
-       iscan_info_t *iscan = NULL;
-
-       if (!dev)
-               return 0;
-
-       
-#ifdef CSCAN
-       params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params)) +
-           (WL_NUMCHANNELS * sizeof(uint16)) + WL_SCAN_PARAMS_SSID_MAX * sizeof(wlc_ssid_t);
-#else
-       params_size = (WL_SCAN_PARAMS_FIXED_SIZE + OFFSETOF(wl_iscan_params_t, params));
-#endif 
-       iscan = kmalloc(sizeof(iscan_info_t), GFP_KERNEL);
-
-       if (!iscan)
-               return -ENOMEM;
-       memset(iscan, 0, sizeof(iscan_info_t));
-
-       
-       iscan->iscan_ex_params_p = (wl_iscan_params_t*)kmalloc(params_size, GFP_KERNEL);
-       if (!iscan->iscan_ex_params_p)
-               return -ENOMEM;
-       iscan->iscan_ex_param_size = params_size;
-       iscan->sysioc_pid = -1;
-       
-       g_iscan = iscan;
-       iscan->dev = dev;
-       iscan->iscan_state = ISCAN_STATE_IDLE;
-
-       g_first_broadcast_scan = BROADCAST_SCAN_FIRST_IDLE;
-       g_iscan->scan_flag = 0;
-
-       
-       iscan->timer_ms    = 3000;
-       init_timer(&iscan->timer);
-       iscan->timer.data = (ulong)iscan;
-       iscan->timer.function = wl_iw_timerfunc;
-
-       sema_init(&iscan->sysioc_sem, 0);
-       init_completion(&iscan->sysioc_exited);
-       iscan->sysioc_pid = kernel_thread(_iscan_sysioc_thread, iscan, 0);
-       if (iscan->sysioc_pid < 0)
-               return -ENOMEM;
-#endif 
-
-       iw = *(wl_iw_t **)netdev_priv(dev);
-       iw->pub = (dhd_pub_t *)dhdp;
-       MUTEX_LOCK_INIT(iw->pub);
-       MUTEX_LOCK_WL_SCAN_SET_INIT();
-#ifdef SOFTAP
-       priv_dev = dev;
-       MUTEX_LOCK_SOFTAP_SET_INIT(iw->pub);
-#endif 
-       g_scan = NULL;
-
-       
-       g_scan = (void *)kmalloc(G_SCAN_RESULTS, GFP_KERNEL);
-       if (!g_scan)
-               return -ENOMEM;
-
-       memset(g_scan, 0, G_SCAN_RESULTS);
-       g_scan_specified_ssid = 0;
-
-#if !defined(CSCAN)
-       
-       wl_iw_init_ss_cache_ctrl();
-#endif 
-       
-       wl_iw_bt_init(dev);
-
-
-       return 0;
-}
-
-void wl_iw_detach(void)
-{
-#if defined(WL_IW_USE_ISCAN)
-       iscan_buf_t  *buf;
-       iscan_info_t *iscan = g_iscan;
-
-       if (!iscan)
-               return;
-       if (iscan->sysioc_pid >= 0) {
-               KILL_PROC(iscan->sysioc_pid, SIGTERM);
-               wait_for_completion(&iscan->sysioc_exited);
-       }
-       MUTEX_LOCK_WL_SCAN_SET();
-       while (iscan->list_hdr) {
-               buf = iscan->list_hdr->next;
-               kfree(iscan->list_hdr);
-               iscan->list_hdr = buf;
-       }
-       MUTEX_UNLOCK_WL_SCAN_SET();
-       kfree(iscan->iscan_ex_params_p);
-       kfree(iscan);
-       g_iscan = NULL;
-#endif 
-
-       if (g_scan)
-               kfree(g_scan);
-
-       g_scan = NULL;
-#if !defined(CSCAN)
-       wl_iw_release_ss_cache_ctrl();
-#endif 
-       wl_iw_bt_release();
-
-#ifdef SOFTAP
-       if (ap_cfg_running) {
-               WL_TRACE(("\n%s AP is going down\n", __FUNCTION__));
-               
-               wl_iw_send_priv_event(priv_dev, "AP_DOWN");
-       }
-#endif
-
-}
index bee5ed62645243f30ccc52c58abdf73f6dbba0e0..a0f326be561e2eb5e4e8c7a95ce164e822a0189f 100755 (executable)
@@ -1,6 +1,9 @@
 config RTL8192CU
        tristate "Realtek 8192C USB WiFi"
        depends on USB
+       select WIRELESS_EXT
+       select WEXT_PRIV
+       select IEEE80211
        ---help---
          Help message of RTL8192CU
 
index 6d0fe423d5edeefaaab5e4cf9dbeabd521792b2b..d5e0ce29cbf6b7ca8037e9929285fb601b9eabb1 100644 (file)
 begin 644 core/rtw_ioctl_set.o
-M?T5,1@$!`0````````````$`*``!``````````````!<$```````!30`````
+M?T5,1@$!`0````````````$`*``!``````````````!4$```````!30`````
 M`"@`$``-``1`+>4`()#E(`!2XQ0``(H``%+C%```"@0PT.4@,$/B<S#OYEX`
 M4^,`0*"3!!"@DP8``)H*``#J!#"`X`$PT^<@,$/B<S#OYEX`4^,$``"*`4"$
 MXG1`[^8$`%+A]?__B@$``.H`0*#C````Z@%`H.,$`*#A$`"]Z![_+^$00"WI
-M`#"@X00@D>4-$=+C$P``&@$#$N,'```:!CN`X@0P@^(#(`+B`@*#X``0H.,0
-M(*#C_O__ZPD``.I7#8#B$`"`XN`0@^+^___K`$!0X@,```H1#H3B`!"@XQ`@
-MH./^___K`0"@XQ"`O>CP02WI`4"@X0%@H.$`4*#A`0!PX@``H#.A#Y#A%0``
-M&@,`4>,3``"*7GV%XBP`A^(!`H#@`!"@XQ`@H./^___K!0"@X2`0A^($(*#A
-M`#"@X_[__^M?3H3B"D"$X@1!A>`$0(3B`#"@XP`PA.4#0%#@`4"@$P```.H`
-M0*#C!`"@X?"!O>AP0"WI`$"@X0%0H.$$8)'E`V'&XP0`5N,`0*##(0``R@@P
-MD>4%`%/C`2"@`Z0W`0,#((0'!@``"@T`4^,`(*`3I#<!$P,@A!<%(*`#I#<!
-M`P,@A`<&`H3@7@V`XBP`@.(,$(7B"""5Y?[__^M?/H;B"C"#X@,QA.`(()7E
-M!""#Y:@W`>,#8(3G!`"@X5X=A.(@$('B!B"@X0$PH./^___K`$!0X@%`H!,$
-M`*#A<("]Z/!'+>D(T$WB`$"@X0%0H.$$,)'E``!3XP(``+H!`1/C+@``"D(!
-M`.H!`1/C*P``"E<-@.(0`(#BX!"$XO[__^L`8%#B!```"J`W`>,#,)3G`@!3
-MX^Q@E@4!```*I#<!XP-@E.<$,-7E``!3XS`!`!H,,)7E`0!SXS$!`!JP(=7A
-M_S\/XP,`4N$M`0`:*`$`Z@@PE>4@`%/C)0$`&DP``.H$`%;C"0``&@@PE>40
-M`%/C!@``"B``4^,=`0`:$#"@XP@PA>4`<*#C!X"@X40``.H%`%;C`0!6$Q4!
-M``H\``#J"#L!XP,PE.<#`%/C$P``BOPW`>,#,)3G``!3XP\``!H(,)7E!0!3
-MXP$@H`.D-P$#`R"$!P8```H-`%/C`""@$Z0W`1,#((07!2"@`Z0W`0,#((0'
-MI#<!XP-@E.<!``#J_#<!XP-@E.=L,)3E(``3XP8```H,,)7E`0!SX_0``!JP
-M(=7A_S\/XP,`4N'P```:`@!6XP,``!H(,)7E(`!3X^L``!H(``#J!`!6XP8`
-M`!H(,)7E$`!3XR``4Q/D```:(`!3XQ`PH`,(,(4%!'"5Y==]X.=L,)3E(``3
-MXP<```H!`!/C`7"@$P>`H!$#```*`P``Z@!PH.,'@*#A````Z@&`H..@-P'C
-M`S"4YP(`4^,E```*!0!6XP$`5A,B```:"""5Y2`@@N*(/@'C`R"$YP1@E>4"
-M8<;CC#X!XP-@A.<(()7ED#X!XP,@A.<@<(7B>HV$XA0`B.('$*#A"""5Y?[_
-M_^L&`H3@7@V`XBP`@.('$*#A"""5Y?[__^M?/H;B"C"#X@,QA.`(()7E!""#
-MY:@W`>,#8(3G!`"@X0@0B.+^___K`4"@XZH``.H$,)7E`@(3XQL```H!`%CC
-M#```&M@!Q>$`(.#C_S\/XP`@`N`!,`/@"!"-XO@@8>%C#83B$`"`X@T0H.$(
-M(*#C_O__ZPX``.K8`<7A`"#@X_\_#^,`(`+@`3`#X`@0C>+X(&'A8PV$X@@`
-M@.(-$*#A"""@X_[__^M0``#J`0!8XTX``!H!`%?C!"#5!08[H`,#((0'!#"5
-MY0,`$^.!```*!FN$X@1@AN(#,`/B`P*&X``0H.,0(*#C_O__ZV%]A.($<(?B
-M!`#5Y0,``.(``H?@`!"@XQ`@H./^___K8HV$X@2`B.($`-7E`P``X@`"B.``
-M$*#C$""@X_[__^L$,)7E`0(3XPL```H#,`/B`P*'X#`0A>(((*#C_O__ZP0`
-MU>4#``#B``*(X#@0A>(((*#C_O__ZPH``.H#,`/B`P*'X#@0A>(((*#C_O__
-MZP0`U>4#``#B``*(X#`0A>(((*#C_O__ZP0`U>4#``#B``*&X"`0A>((()7E
-M_O__ZP0PE>4#,`/B!#"%Y0$PH./X*@'C`C#$YP`0H./Z*@'C`A#$YP0`H.%>
-M'83B(!"!X@0@E>7^___K`$!0X@%`H!,Z``#J5PV$XA``@.+@$(3B_O__ZP"`
-M4.(!0*`#,P``"A&NB.(*`*#A`!"@XQ`@H./^___K()"%X@H`H.$)$*#A$""@
-MX_[__^L"`%;C%@``&@`@H./Y.@'C`R#$YP0PE>4!`A/C"```"O``B.(0$(GB
-M"""@X_[__^L!#(CB&!")X@@@H./^___K!P``ZO``B.(8$(GB"""@X_[__^L!
-M#(CB$!")X@@@H./^___K``!7XP4```H$`*#A"!"@X0`@H./^___K`$"@X00`
-M`.H$`*#A"!"@X0$@H./^___K`$"@X0!`5.(!0*`3````Z@!`H.,$`*#A"-"-
-MXO"'O>@"`%;CU/[_&L_^_^H00"WI7DV`XB!`A.((.P'C`Q"`YP,`4>,"(*"#
-MH#<!@P,@@(<$$*#A_O__ZP$`4.,``*`3`0"@`Q"`O>AP0"WI*-!-X@!`4.(>
-M```*=34#XP,PU.<``%/C&@``"FPPE.4B#1/C&0``&@PUU.4!`%/C%@``"O[_
-M_^L-,*#A?VW#XS]@QN,$,);E`3"#X@0PAN4$4(WB!0"@X0`0H.,D(*#C_O__
-MZP0`H.$%$*#A_O__ZP!`H.$$,);E`3!#X@0PAN7^___K`@``Z@!`H.,```#J
-M`4"@XP0`H.$HT(WB<("]Z!!`+>D`0*#A_O__ZPT@H.%_/<+C/S##XP0@D^4!
-M((+B!""#Y6PPE.4!`!/C!0``"@0`H.'^___K!`"@X?[__^L$`*#A_O__ZPT@
-MH.%_/<+C/S##XP0@D^4!($+B!""#Y?[__^L!`*#C$("]Z'!`+>D`0*#A`5"@
-MX3@QD.4!`%/A/@``"O[__^L-(*#A?SW"XS\PP^,$()/E`2""X@0@@^5L,)3E
-M`0`3XP(``!HX(93E``!2XP0``!H$`*#A_O__ZVPPE.4!`!/C`0``&D``$^,$
-M```*!`"@X?[__^ML,)3E`0`3XP0``!HX,93E`0!3XP$```H``%/C`0``&@0`
-MH.'^___K.#&4Y00`4^,#```:`##@X]@PA.4$`*#A_O__ZSA1A.5L,)3E>###
-MXVPPA.4!`%7C"#"#`VPPA`4(```*(#"#,VPPA#4%```Z!`!5XP,``!H0,(/C
-M;#"$Y00`H.'^___K#2"@X7\]PN,_,,/C!""3Y0$@0N($((/E_O__ZP$`H.-P
-M@+WH<$`MZ0!`H.&$4)#E`3#@X]@P@.5L,)#E@#"#XVPP@.5X4(#E`3"@XW`P
-MP.6$`(#B_O__ZP$`4.,-```:;#"4Y8`PP^-L,(3E##74Y0``4^,"```*<3#4
-MY0``4^,\```*!`"@X900A.+^___K`$"@X3@``.IL`(3B_O__ZP$`4.,+```:
-M`#"@XW`PQ.4`,`#C`#!`XP`0D^5%#H3B"`"`XJ(?@>("$('B_O__ZP%`H.,H
-M``#J;#"4Y2``$^,7```*0#"@XVPPA.6I;83B)5"&X@4`H.$`$*#C)""@X_[_
-M_^L%`*#AE!"$XB0@H./^___K!`"@X?[__^L=`(;B_O__ZP0`H.'^___K`0!0
-MXP!`H!,`,*`#<##$!0%`H`,-``#J@###XVPPA.4,-=3E``!3XP(```IQ,-3E
-M``!3XP0```H$`*#AE!"$XO[__^L`0*#A````Z@%`H.,$`*#A<("]Z/!!+>D`
-M4*#A`7"@X74U`^,#,-#G``!3XP!`H`-O```*;#"0Y8``$^,!0*`3:P``&@(+
-M$^-K```:$```ZFPPE>4""Q/C!0``"@8`H.'^___K`4!$X@$`=./W__\:`0``
-MZ@``5.,%``#*C`&?Y8P1G^7^___K;$"5Y=1#X.=0``#J_O__ZPT@H.%_/<+C
-M/S##XP0@D^4!((+B!""#Y6PPE>5!`!/C,P``"I0@E>4`,)?E`P!2X2$``!J8
-M`(7B!!"'XO[__^L!`%#C'```&FPPE>4(`!/C%```&@4`H.'`$(7B_O__ZP``
-M4.,!0*`3-```&@4`H.'^___K;#"5Y0$`$^,!```*!0"@X?[__^L%`*#A_O__
-MZVPPE>5``!/C0###$R`P@Q-L,(45$@``Z@4`H.$!$*#C`2"@X?[__^L-``#J
-M!0"@X?[__^ML,)7E`0`3XP$```H%`*#A_O__ZP4`H.'^___K;#"5Y4``$^-`
-M,,,3(#"#$VPPA14F/*#C`S#5YP$`4^,-```*!P"@X?[__^L``%#C"0``"I0`
-MA>('$*#A)""@X_[__^L`,*#CB#2%Y04`H.'^___K`$"@X0```.H`0*#C#2"@
-MX7\]PN,_,,/C!""3Y0$@0N($((/E_O__ZP0`H.'P@;WH9`"@X_[__^LP0*#C
-M9&"@XX___^H``````````'!`+>D`0*#A`5"@X0`PT>4``%/C#P``&@$@T>4`
-M`%+C#```&@(PT>4``%/C&@``&@,PT>4``%/C%P``&@0PT>4``%/C%```&@4P
-MT>4``%/C$0``&D<``.K_`%/C#@``&@$PU>7_`%/C"P``&@(PU>7_`%/C"```
-M&@,PU>7_`%/C!0``&@0PU>7_`%/C`@``&@4PU>7_`%/C-@``"O[__^L-(*#A
-M?SW"XS\PP^,$()/E`2""X@0@@^5L,)3E(@T3X]-#X!<C```:00`3XQ@```K@
-M`(3B!1"@X08@H./^___K`0!0XP0``!IL,)3E"``3XP%`H`,7```*#0``Z@0`
-MH.'^___K;#"4Y0$`$^,!```*!`"@X?[__^L$`*#A_O__ZVPPE.5``!/C0###
-M$R`P@Q-L,(05N`"$X@40H.$&(*#C_O__ZP$PH..(-(3E!`"@X?[__^L`0*#A
-M#2"@X7\]PN,_,,/C!""3Y0$@0N($((/E_O__ZP```.H`0*#C!`"@X7"`O>@`
-M````L+"@@'P```"PL*B`Z````+"PK(!L`0``L+"J@!P"``"PK@&`;`<``+"P
-MJ("H!P``L*H)@$P(``"PL*B`N`@``+"PJH#4"0``L+"J@#0+``"PL*R`.`T`
-M`+"PJH!R='=?<V5T7S@P,E\Q,5]S<VED`"5S.B!3970@4U-)1"!I<R!N;W0@
-M86QL;W=E9"!U;F1E<B!S=7)V97EI;F<*``````!'0T,Z("A'3E4I(#0N-"XP
-M`$$J````865A8FD``2`````%-RU!``8*!T$(`1($%`$5`1<#&`$9`1H"'@$`
-M+G-Y;71A8@`N<W1R=&%B`"YS:'-T<G1A8@`N<F5L+G1E>'0`+F1A=&$`+F)S
-M<P`N05)-+F5X=&%B`"YR96PN05)-+F5X:61X`"YR;V1A=&$`+G)O9&%T82YS
-M='(Q+C0`+F-O;6UE;G0`+FYO=&4N1TY5+7-T86-K`"Y!4DTN871T<FEB=71E
-M<P```````````````````````````````````````````````````````!\`
-M```!````!@`````````T````O`X`````````````!``````````;````"0``
-M````````````$!H``+@"```.`````0````0````(````)0````$````#````
-M`````/`.```````````````````!`````````"L````(`````P````````#P
-M#@```````````````````0`````````P`````0````(`````````\`X`````
-M``````````````$`````````/P````$``'""`````````/`.``!@`````0``
-M```````$`````````#L````)``````````````#('```:`````X````&````
-M!`````@```!*`````0````(`````````4`\``!0```````````````0`````
-M````4@````$````R`````````&0/```P```````````````$`````0```&$`
-M```!``````````````"4#P``$@```````````````0````````!J`````0``
-M````````````I@\```````````````````$`````````>@````,``'``````
-M`````*8/```K```````````````!`````````!$````#``````````````#1
-M#P``B@```````````````0`````````!`````@``````````````W!(``!`$
-M```/````&@````0````0````"0````,``````````````.P6```C`P``````
-M```````!```````````````````````````````!```````````````$`/'_
-M`````````````````P`!``````````````````,``P`````````````````#
-M``0`$0`````````````````!``````````````````,`!0``````````````
-M```#``8`$0```'P````````````!`!$```#H`````````````0`1````;`$`
-M``````````$`$0```!P"```````````!`!$```!L!P```````````0`1````
-MJ`<```````````$`$0```$P(```````````!`!$```"X"````````````0`1
-M````U`D```````````$`$0```#0+```````````!`!0````P#0``````````
-M`0`1````.`T```````````$``````````````````P`(`!<`````````%```
-M``$`"``````````````````#``D``````````````````P`+````````````
-M``````,`"@`````````````````#``P`)@````````!\````$@`!`#@`````
-M`````````!````!/````?````&P````2``$`:0``````````````$````'4`
-M`````````````!````"%````Z````(0````2``$`GP``````````````$```
-M`*L```!L`0``L````!(``0#"```````````````0````S@```!P"``!0!0``
-M$@`!`.4``````````````!````#W````;`<``#P````2``$`&@$`````````
-M````$````"<!``"H!P``I````!(``0!&`0`````````````0````5P$`````
-M````````$````&H!`````````````!````!Z`0``3`@``&P````2``$`E@$`
-M````````````$````*<!`````````````!````"_`0`````````````0````
-MV`$``+@(```<`0``$@`!`/L!`````````````!`````(`@`````````````0
-M````%@(``-0)``!@`0``$@`!`"("`````````````!`````S`@``````````
-M```0````6@(`````````````$````&("`````````````!````!L`@``````
-M```````0````D`(`````````````$````*D"`````````````!````"[`@``
-M-`L```0"```2``$`SP(`````````````$````-8"`````````````!````#=
-M`@`````````````0````Z0(`````````````$````/H"`````````````!``
-M```.`P``.`T``(0!```2``$``')T=U]I;V-T;%]S970N8P`D80`D9`!?7V9U
-M;F-?7RXS-#8V-0!R='=?=F%L:61A=&5?<W-I9`!?7V%E86)I7W5N=VEN9%]C
-M<'!?<'(P`')T=U]S971?.#`R7S$Q7W)E;6]V95]K97D`7W)T=U]M96US970`
-M<G1W7V=E=%]S=&%I;F9O`')T=U]S971?.#`R7S$Q7W)E;6]V95]W97``<G1W
-M7W-E=%]K97D`<G1W7W-E=%\X,#)?,3%?861D7W=E<`!?<G1W7VUE;6-P>0!R
-M='=?<V5T7S@P,E\Q,5]A9&1?:V5Y`')T=U]S971S=&%K97E?8VUD`')T=U]S
-M971?.#`R7S$Q7V%U=&AE;G1I8V%T:6]N7VUO9&4`<G1W7W-E=%]A=71H`')T
-M=U]S971?.#`R7S$Q7V)S<VED7VQI<W1?<V-A;@!L;V-A;%]B:%]D:7-A8FQE
-M`')T=U]S:71E<W5R=F5Y7V-M9`!L;V-A;%]B:%]E;F%B;&4`<G1W7W-E=%\X
-M,#)?,3%?9&ES87-S;V-I871E`')T=U]D:7-A<W-O8U]C;60`<G1W7VEN9&EC
-M871E7V1I<V-O;FYE8W0`<G1W7V9R965?87-S;V-?<F5S;W5R8V5S`')T=U]S
-M971?.#`R7S$Q7VEN9G)A<W1R=6-T=7)E7VUO9&4`<W1O<%]A<%]M;V1E`'-T
-M87)T7V%P7VUO9&4`<G1W7V1O7VIO:6X`7W)T=U]Q=65U95]E;7!T>0!R='=?
-M<V5L96-T7V%N9%]J;VEN7V9R;VU?<V-A;FYE9%]Q=65U90!J:69F:65S`&UO
-M9%]T:6UE<@!R='=?=7!D871E7W)E9VES=')Y<')I=E]D979?;F5T=V]R:P!R
-M='=?9V5N97)A=&5?<F%N9&]M7VEB<W,`<G1W7V-R96%T96)S<U]C;60`<G1W
-M7W-E=%\X,#)?,3%?<W-I9`!M<VQE97``<')I;G1K`%]R='=?;65M8VUP`')T
-M=U]I<U]S86UE7VEB<W,`<G1W7VQP<U]C=')L7W=K7V-M9`!R='=?<V5T7S@P
-M,E\Q,5]B<W-I9```L````!P=``#$````'!X``-P````<'0``)`$``!P=```X
-M`0``'"```-0!```<(@``"`(``!P@``!8`@``'!X``%P$```<(@``=`0``!PB
-M``"<!```'"$``.@$```<(@``'`4``!PB``!@!0``'!T``(`%```<'0``H`4`
-M`!P=``#`!0``'"(``-@%```<(@``\`4``!PB```(!@``'"(``"`&```<(@``
-M6`8``!P@``!T!@``'!X``)0&```<'0``J`8``!PB``#8!@``'"(``.@&```<
-M(@``_`8``!PB```,!P``'"(``"0'```<)```/`<``!PD``"4!P``'"8``.`'
-M```<*```#`@``!P=```8"```'"D``"P(```<*@``5`@``!PH``"`"```'"P`
-M`(@(```<+0``D`@``!PN``"L"```'"H``-`(```<*```"`D``!PL```D"0``
-M'"X``$P)```<+0``:`D``!PP``"L"0``'#$``,@)```<*@``!`H``!PS```\
-M"@``'"D``$P*```<-```8`H``"LU``!D"@``+#4``'P*```<-@``L`H``!P=
-M``#`"@``'"(``,@*```<-P``T`H``!PX``#8"@``'#D``!P+```<*0``@`L`
-M`!P[``"D"P``'#P``+0+```<*```]`L``!P]```4#```'#X``"@,```<+```
-M/`P``!PM``!$#```'"X``&P,```</P``>`P``!PL``",#```'"T``)0,```<
-M+@``P`P``!P:``#8#```'"(``.@,```<,@``$`T``!PJ```@#0``'#L``#`-
-M```"%@``-`T```(4``#4#0``'"@``!0.```</0``.`X``!PL``!,#@``'"T`
-M`%0.```<+@``>`X``!PB``"(#@``'#(``*@.```<*@```````"H"````````
-M`!L```@````J`@``$````"H"```8````*@(``"`````J`@``*````"H"```P
-M````*@(``#@````J`@``0````"H"``!(````*@(``%`````J`@``6````"H"
-"````
+M`#"@X00@D>4-$=+C$P``&@$#$N,'```:!CN`XAPP@^(#(`+B`@*#X``0H.,0
+M(*#C_O__ZPD``.I7#8#B*`"`XN`0@^+^___K`$!0X@,```H1#H3B`!"@XQ`@
+MH./^___K`0"@XQ"`O>AP0"WI`4"@X0%@H.$`4*#A`0!PX@``H#.A#Y#A%0``
+M&@,`4>,3``"*7PV%X@0`@.(!`H#@`!"@XQ`@H./^___K!0"@X5X=A>(X$('B
+M!""@X0`PH./^___K!DR$X@11A>`$4(7B`#"@XP`PA>4#0%#@`4"@$P```.H`
+M0*#C!`"@X7"`O>AP0"WI`$"@X0%0H.$$8)'E`V'&XP0`5N,`0*##(```R@@P
+MD>4%`%/C`2"@`[PW`0,#((0'!@``"@T`4^,`(*`3O#<!$P,@A!<%(*`#O#<!
+M`P,@A`=?#X;B``*$X`0`@.(,$(7B"""5Y?[__^L&/(;B`S&$X`@@E>4$((/E
+M7SV@XP-@A.<$`*#A7AV$XC@0@>(&(*#A`3"@X_[__^L`0%#B`4"@$P0`H.%P
+M@+WH\$<MZ0C03>(`0*#A`5"@X00PD>4``%/C`@``N@$!$^,N```*00$`Z@$!
+M$^,K```*5PV`XB@`@.+@$(3B_O__ZP!@4.($```*N#<!XP,PE.<"`%/C[&"6
+M!0$```J\-P'C`V"4YP0PU>4``%/C+P$`&@PPE>4!`'/C,`$`&K`AU>'_/P_C
+M`P!2X2P!`!HG`0#J"#"5Y2``4^,D`0`:3```Z@0`5N,)```:"#"5Y1``4^,&
+M```*(`!3XQP!`!H0,*#C"#"%Y0!PH.,'@*#A1```Z@4`5N,!`%83%`$`"CP`
+M`.H@.P'C`S"4YP,`4^,3``"*%#@!XP,PE.<``%/C#P``&@@PE>4%`%/C`2"@
+M`[PW`0,#((0'!@``"@T`4^,`(*`3O#<!$P,@A!<%(*`#O#<!`P,@A`>\-P'C
+M`V"4YP$``.H4.`'C`V"4YVPPE.4@`!/C!@``"@PPE>4!`'/C\P``&K`AU>'_
+M/P_C`P!2X>\``!H"`%;C`P``&@@PE>4@`%/CZ@``&@@``.H$`%;C!@``&@@P
+ME>40`%/C(`!3$^,``!H@`%/C$#"@`P@PA04$<)7EUWW@YVPPE.4@`!/C!P``
+M"@$`$^,!<*`3!X"@$0,```H#``#J`'"@XP>`H.$```#J`8"@X[@W`>,#,)3G
+M`@!3XR0```H%`%;C`0!6$R$``!H(()7E("""XJ`^`>,#((3G!&"5Y0)AQN.D
+M/@'C`V"$YP@@E>6H/@'C`R"$YR!PA>)ZC83B+`"(X@<0H.$(()7E_O__ZU\/
+MAN(``H3@!`"`X@<0H.$(()7E_O__ZP8\AN(#,83@"""5Y00@@^5?/:#C`V"$
+MYP0`H.$@$(CB_O__ZP%`H..J``#J!#"5Y0("$^,;```*`0!8XPP``!K8`<7A
+M`"#@X_\_#^,`(`+@`3`#X`@0C>+X(&'A8PV$XB@`@.(-$*#A"""@X_[__^L.
+M``#JV`'%X0`@X./_/P_C`"`"X`$P`^`($(WB^"!AX6,-A.(@`(#B#1"@X0@@
+MH./^___K4```Z@$`6.-.```:`0!7XP0@U048.`$#`R"$!P0PE>4#`!/C@0``
+M"@9KA.(<8(;B`S`#X@,"AN``$*#C$""@X_[__^MA?83B''"'X@0`U>4#``#B
+M``*'X``0H.,0(*#C_O__ZV*-A.(<@(CB!`#5Y0,``.(``HC@`!"@XQ`@H./^
+M___K!#"5Y0$"$^,+```*`S`#X@,"A^`P$(7B"""@X_[__^L$`-7E`P``X@`"
+MB.`X$(7B"""@X_[__^L*``#J`S`#X@,"A^`X$(7B"""@X_[__^L$`-7E`P``
+MX@`"B.`P$(7B"""@X_[__^L$`-7E`P``X@`"AN`@$(7B"""5Y?[__^L$,)7E
+M`S`#X@0PA>4!,*#C$"L!XP(PQ.<`$*#C$BL!XP(0Q.<$`*#A7AV$XC@0@>($
+M()7E_O__ZP!`4.(!0*`3.@``ZE<-A.(H`(#BX!"$XO[__^L`@%#B`4"@`S,`
+M``H1KHCB"@"@X0`0H.,0(*#C_O__ZR"0A>(*`*#A"1"@X1`@H./^___K`@!6
+MXQ8``!H`(*#C$3L!XP,@Q.<$,)7E`0(3XP@```KP`(CB$!")X@@@H./^___K
+M`0R(XA@0B>(((*#C_O__ZP<``.KP`(CB&!")X@@@H./^___K`0R(XA`0B>((
+M(*#C_O__ZP``5^,%```*!`"@X0@0H.$`(*#C_O__ZP!`H.$$``#J!`"@X0@0
+MH.$!(*#C_O__ZP!`H.$`0%3B`4"@$P```.H`0*#C!`"@X0C0C>+PA[WH`@!6
+MX]7^_QK0_O_J$$`MZ5Y-@.(X0(3B(#L!XP,0@.<#`%'C`B"@@[@W`8,#(("'
+M!!"@X?[__^L!`%#C``"@$P$`H`,0@+WH<$`MZ2C03>(`0%#B'@``"ITU`^,#
+M,-3G``!3XQH```IL,)3E(@T3XQD``!H4-=3E`0!3XQ8```K^___K#3"@X7]M
+MP^,_8,;C!#"6Y0$P@^($,(;E!%"-X@4`H.$`$*#C)""@X_[__^L$`*#A!1"@
+MX?[__^L`0*#A!#"6Y0$P0^($,(;E_O__ZP(``.H`0*#C````Z@%`H.,$`*#A
+M*-"-XG"`O>@00"WI`$"@X?[__^L-(*#A?SW"XS\PP^,$()/E`2""X@0@@^5L
+M,)3E`0`3XP4```H$`*#A_O__ZP0`H.'^___K!`"@X?[__^L-(*#A?SW"XS\P
+MP^,$()/E`2!"X@0@@^7^___K`0"@XQ"`O>AP0"WI`$"@X0%0H.$X,9#E`0!3
+MX3X```K^___K#2"@X7\]PN,_,,/C!""3Y0$@@N($((/E;#"4Y0$`$^,"```:
+M."&4Y0``4N,$```:!`"@X?[__^ML,)3E`0`3XP$``!I``!/C!```"@0`H.'^
+M___K;#"4Y0$`$^,$```:.#&4Y0$`4^,!```*``!3XP$``!H$`*#A_O__ZS@Q
+ME.4$`%/C`P``&@`PX./8,(3E!`"@X?[__^LX483E;#"4Y7@PP^-L,(3E`0!5
+MXP@P@P-L,(0%"```"B`P@S-L,(0U!0``.@0`5>,#```:$#"#XVPPA.4$`*#A
+M_O__ZPT@H.%_/<+C/S##XP0@D^4!($+B!""#Y?[__^L!`*#C<("]Z'!`+>D`
+M0*#AA%"0Y0$PX./8,(#E;#"0Y8`P@^-L,(#E>%"`Y0$PH.-P,,#EA`"`XO[_
+M_^L!`%#C#0``&FPPE.6`,,/C;#"$Y10UU.4``%/C`@``"G$PU.4``%/C/```
+M"@0`H.&4$(3B_O__ZP!`H.$X``#J;`"$XO[__^L!`%#C"P``&@`PH.-P,,3E
+M`#``XP`P0.,`$)/E10Z$X@@`@.*B'X'B`A"!XO[__^L!0*#C*```ZFPPE.4@
+M`!/C%P``"D`PH.-L,(3EJ6V$XCU0AN(%`*#A`!"@XR0@H./^___K!0"@X900
+MA.(D(*#C_O__ZP0`H.'^___K-0"&XO[__^L$`*#A_O__ZP$`4.,`0*`3`#"@
+M`W`PQ`4!0*`##0``ZH`PP^-L,(3E%#74Y0``4^,"```*<3#4Y0``4^,$```*
+M!`"@X900A.+^___K`$"@X0```.H!0*#C!`"@X7"`O>CP02WI`%"@X0%PH.&=
+M-0/C`S#0YP``4^,`0*`#;P``"FPPD.6``!/C`4"@$VL``!H""Q/C:P``&A``
+M`.IL,)7E`@L3XP4```H&`*#A_O__ZP%`1.(!`'3C]___&@$``.H``%3C!0``
+MRHP!G^6,$9_E_O__ZVQ`E>740^#G4```ZO[__^L-(*#A?SW"XS\PP^,$()/E
+M`2""X@0@@^5L,)7E00`3XS,```J4()7E`#"7Y0,`4N$A```:F`"%X@00A^+^
+M___K`0!0XQP``!IL,)7E"``3XQ0``!H%`*#AP!"%XO[__^L``%#C`4"@$S0`
+M`!H%`*#A_O__ZVPPE>4!`!/C`0``"@4`H.'^___K!0"@X?[__^ML,)7E0``3
+MXT`PPQ,@,(,3;#"%%1(``.H%`*#A`1"@XP$@H.'^___K#0``Z@4`H.'^___K
+M;#"5Y0$`$^,!```*!0"@X?[__^L%`*#A_O__ZVPPE>5``!/C0###$R`P@Q-L
+M,(45&#8"XP,PU><!`%/C#0``"@<`H.'^___K``!0XPD```J4`(7B!Q"@X20@
+MH./^___K`#"@XXPTA>4%`*#A_O__ZP!`H.$```#J`$"@XPT@H.%_/<+C/S##
+MXP0@D^4!($+B!""#Y?[__^L$`*#A\(&]Z&0`H./^___K,$"@XV1@H../___J
+M``````````!P0"WI`$"@X0%0H.$`,-'E``!3XP\``!H!(-'E``!2XPP``!H"
+M,-'E``!3XQH``!H#,-'E``!3XQ<``!H$,-'E``!3XQ0``!H%,-'E``!3XQ$`
+M`!I'``#J_P!3XPX``!H!,-7E_P!3XPL``!H",-7E_P!3XP@``!H#,-7E_P!3
+MXP4``!H$,-7E_P!3XP(``!H%,-7E_P!3XS8```K^___K#2"@X7\]PN,_,,/C
+M!""3Y0$@@N($((/E;#"4Y2(-$^/30^`7(P``&D$`$^,8```*X`"$X@40H.$&
+M(*#C_O__ZP$`4.,$```:;#"4Y0@`$^,!0*`#%P``"@T``.H$`*#A_O__ZVPP
+ME.4!`!/C`0``"@0`H.'^___K!`"@X?[__^ML,)3E0``3XT`PPQ,@,(,3;#"$
+M%;@`A.(%$*#A!B"@X_[__^L!,*#CC#2$Y00`H.'^___K`$"@X0T@H.%_/<+C
+M/S##XP0@D^4!($+B!""#Y?[__^L```#J`$"@XP0`H.%P@+WH`````+"PH(!\
+M````L+"H@.@```"PL*J`;`$``+"PJH`8`@``L*X!@&0'``"PL*B`H`<``+"J
+M"8!$"```L+"H@+`(``"PL*J`S`D``+"PJH`L"P``L+"L@#`-``"PL*J`<G1W
+M7W-E=%\X,#)?,3%?<W-I9``E<SH@4V5T(%-3240@:7,@;F]T(&%L;&]W960@
+M=6YD97(@<W5R=F5Y:6YG"@``````1T-#.B`H1TY5*2`T+C0N,`!!*@```&%E
+M86)I``$@````!3<M00`&"@=!"`$2!!0!%0$7`Q@!&0$:`AX!`"YS>6UT86(`
+M+G-T<G1A8@`N<VAS=')T86(`+G)E;"YT97AT`"YD871A`"YB<W,`+D%232YE
+M>'1A8@`N<F5L+D%232YE>&ED>``N<F]D871A`"YR;V1A=&$N<W1R,2XT`"YC
+M;VUM96YT`"YN;W1E+D=.52US=&%C:P`N05)-+F%T=')I8G5T97,`````````
+M```````````````````````````````````````````````?`````0````8`
+M````````-````+0.``````````````0`````````&P````D`````````````
+M``@:``"X`@``#@````$````$````"````"4````!`````P````````#H#@``
+M`````````````````0`````````K````"`````,`````````Z`X`````````
+M``````````$`````````,`````$````"`````````.@.````````````````
+M```!`````````#\````!``!P@@````````#H#@``8`````$`````````!```
+M```````[````"0``````````````P!P``&@````.````!@````0````(````
+M2@````$````"`````````$@/```4```````````````$`````````%(````!
+M````,@````````!<#P``,```````````````!`````$```!A`````0``````
+M````````C`\``!(```````````````$`````````:@````$`````````````
+M`)X/```````````````````!`````````'H````#``!P``````````">#P``
+M*P```````````````0`````````1`````P``````````````R0\``(H`````
+M``````````$``````````0````(``````````````-02```0!```#P```!H`
+M```$````$`````D````#``````````````#D%@``(P,``````````````0``
+M`````````````````````````````0``````````````!`#Q_P``````````
+M``````,``0`````````````````#``,``````````````````P`$`!$`````
+M`````````````0`````````````````#``4``````````````````P`&`!$`
+M``!\`````````````0`1````Z`````````````$`$0```&P!```````````!
+M`!$````8`@```````````0`1````9`<```````````$`$0```*`'````````
+M```!`!$```!$"````````````0`1````L`@```````````$`$0```,P)````
+M```````!`!$````L"P```````````0`4````*`T```````````$`$0```#`-
+M```````````!``````````````````,`"``7`````````!0````!``@`````
+M`````````````P`)``````````````````,`"P`````````````````#``H`
+M`````````````````P`,`"8`````````?````!(``0`X```````````````0
+M````3P```'P```!L````$@`!`&D``````````````!````!U````````````
+M```0````A0```.@```"$````$@`!`)\``````````````!````"K````;`$`
+M`*P````2``$`P@``````````````$````,X````8`@``3`4``!(``0#E````
+M```````````0````]P```&0'```\````$@`!`!H!`````````````!`````G
+M`0``H`<``*0````2``$`1@$`````````````$````%<!`````````````!``
+M``!J`0`````````````0````>@$``$0(``!L````$@`!`)8!````````````
+M`!````"G`0`````````````0````OP$`````````````$````-@!``"P"```
+M'`$``!(``0#[`0`````````````0````"`(`````````````$````!8"``#,
+M"0``8`$``!(``0`B`@`````````````0````,P(`````````````$````%H"
+M`````````````!````!B`@`````````````0````;`(`````````````$```
+M`)`"`````````````!````"I`@`````````````0````NP(``"P+```$`@``
+M$@`!`,\"`````````````!````#6`@`````````````0````W0(`````````
+M````$````.D"`````````````!````#Z`@`````````````0````#@,``#`-
+M``"$`0``$@`!``!R='=?:6]C=&Q?<V5T+F,`)&$`)&0`7U]F=6YC7U\N,SDP
+M,C,`<G1W7W9A;&ED871E7W-S:60`7U]A96%B:5]U;G=I;F1?8W!P7W!R,`!R
+M='=?<V5T7S@P,E\Q,5]R96UO=F5?:V5Y`%]R='=?;65M<V5T`')T=U]G971?
+M<W1A:6YF;P!R='=?<V5T7S@P,E\Q,5]R96UO=F5?=V5P`')T=U]S971?:V5Y
+M`')T=U]S971?.#`R7S$Q7V%D9%]W97``7W)T=U]M96UC<'D`<G1W7W-E=%\X
+M,#)?,3%?861D7VME>0!R='=?<V5T<W1A:V5Y7V-M9`!R='=?<V5T7S@P,E\Q
+M,5]A=71H96YT:6-A=&EO;E]M;V1E`')T=U]S971?875T:`!R='=?<V5T7S@P
+M,E\Q,5]B<W-I9%]L:7-T7W-C86X`;&]C86Q?8FA?9&ES86)L90!R='=?<VET
+M97-U<G9E>5]C;60`;&]C86Q?8FA?96YA8FQE`')T=U]S971?.#`R7S$Q7V1I
+M<V%S<V]C:6%T90!R='=?9&ES87-S;V-?8VUD`')T=U]I;F1I8V%T95]D:7-C
+M;VYN96-T`')T=U]F<F5E7V%S<V]C7W)E<V]U<F-E<P!R='=?<V5T7S@P,E\Q
+M,5]I;F9R87-T<G5C='5R95]M;V1E`'-T;W!?87!?;6]D90!S=&%R=%]A<%]M
+M;V1E`')T=U]D;U]J;VEN`%]R='=?<75E=65?96UP='D`<G1W7W-E;&5C=%]A
+M;F1?:F]I;E]F<F]M7W-C86YN961?<75E=64`:FEF9FEE<P!M;V1?=&EM97(`
+M<G1W7W5P9&%T95]R96=I<W1R>7!R:79?9&5V7VYE='=O<FL`<G1W7V=E;F5R
+M871E7W)A;F1O;5]I8G-S`')T=U]C<F5A=&5B<W-?8VUD`')T=U]S971?.#`R
+M7S$Q7W-S:60`;7-L965P`'!R:6YT:P!?<G1W7VUE;6-M<`!R='=?:7-?<V%M
+M95]I8G-S`')T=U]L<'-?8W1R;%]W:U]C;60`<G1W7W-E=%\X,#)?,3%?8G-S
+M:60``+`````<'0``Q````!P>``#<````'!T``"0!```<'0``/`$``!P@``#4
+M`0``'"(```0"```<(```5`(``!P>``!8!```'"(``'`$```<(@``E`0``!PA
+M``#@!```'"(``!0%```<(@``6`4``!P=``!X!0``'!T``)@%```<'0``N`4`
+M`!PB``#0!0``'"(``.@%```<(@````8``!PB```8!@``'"(``%`&```<(```
+M;`8``!P>``",!@``'!T``*`&```<(@``T`8``!PB``#@!@``'"(``/0&```<
+M(@``!`<``!PB```<!P``'"0``#0'```<)```C`<``!PF``#8!P``'"@```0(
+M```<'0``$`@``!PI```D"```'"H``$P(```<*```>`@``!PL``"`"```'"T`
+M`(@(```<+@``I`@``!PJ``#("```'"@````)```<+```'`D``!PN``!$"0``
+M'"T``&`)```<,```I`D``!PQ``#`"0``'"H``/P)```<,P``-`H``!PI``!$
+M"@``'#0``%@*```K-0``7`H``"PU``!T"@``'#8``*@*```<'0``N`H``!PB
+M``#`"@``'#<``,@*```<.```T`H``!PY```4"P``'"D``'@+```<.P``G`L`
+M`!P\``"L"P``'"@``.P+```</0``#`P``!P^```@#```'"P``#0,```<+0``
+M/`P``!PN``!D#```'#\``'`,```<+```A`P``!PM``",#```'"X``+@,```<
+M&@``T`P``!PB``#@#```'#(```@-```<*@``&`T``!P[```H#0```A8``"P-
+M```"%```S`T``!PH```,#@``'#T``#`.```<+```1`X``!PM``!,#@``'"X`
+M`'`.```<(@``@`X``!PR``"@#@``'"H````````J`@`````````;```(````
+M*@(``!`````J`@``&````"H"```@````*@(``"@````J`@``,````"H"```X
+G````*@(``$`````J`@``2````"H"``!0````*@(``%@````J`@``
 `
 end
index c0a62a380cf02dcf722c503608584a191537e54b..9135df278088280cca2de417fa3cf52dfdbb1046 100755 (executable)
@@ -5605,6 +5605,10 @@ void issue_auth(_adapter *padapter, struct sta_info *psta, unsigned short status
        struct xmit_priv                        *pxmitpriv = &(padapter->xmitpriv);
        struct mlme_ext_priv    *pmlmeext = &(padapter->mlmeextpriv);
        struct mlme_ext_info    *pmlmeinfo = &(pmlmeext->mlmext_info);
+       /*
+        * Send a deauth message before auth. (meitu's disconnect issue)
+        */
+       issue_deauth( padapter, (&(pmlmeinfo->network))->MacAddress, WLAN_REASON_DEAUTH_LEAVING);
 
        if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL)
        {
@@ -5909,20 +5913,24 @@ void issue_assocreq(_adapter *padapter)
        struct ieee80211_hdr                    *pwlanhdr;
        unsigned short                          *fctrl;
        unsigned short                          val16;
-       unsigned int                                    i, ie_len;
-       unsigned char                                   rf_type, bssrate[NumRates];
+       unsigned int                                    i, j, ie_len, index=0;
+       unsigned char                                   rf_type, bssrate[NumRates], sta_bssrate[NumRates];
        PNDIS_802_11_VARIABLE_IEs       pIE;
        struct registry_priv    *pregpriv = &padapter->registrypriv;
        struct xmit_priv                *pxmitpriv = &(padapter->xmitpriv);
        struct mlme_ext_priv    *pmlmeext = &(padapter->mlmeextpriv);
        struct mlme_ext_info    *pmlmeinfo = &(pmlmeext->mlmext_info);
-       int     bssrate_len = 0;
+       int     bssrate_len = 0, sta_bssrate_len = 0;
 #ifdef CONFIG_P2P
        struct wifidirect_info  *pwdinfo = &(padapter->wdinfo);
        u8                                      p2pie[ 255 ] = { 0x00 };
        u16                                     p2pielen = 0;   
 #endif //CONFIG_P2P
 
+#ifdef CONFIG_DFS
+       u16     cap;
+#endif //CONFIG_DFS
+
        if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL)
        {
                return;
@@ -5952,8 +5960,13 @@ void issue_assocreq(_adapter *padapter)
        pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr);
 
        //caps
-
+#ifdef CONFIG_DFS
+       _rtw_memcpy(&cap, rtw_get_capability_from_ie(pmlmeinfo->network.IEs), 2);
+       cap |= BIT(8);
+       _rtw_memcpy(pframe, &cap, 2);
+#else
        _rtw_memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.IEs), 2);
+#endif //CONFIG_DFS
 
        pframe += 2;
        pattrib->pktlen += 2;
@@ -5969,15 +5982,56 @@ void issue_assocreq(_adapter *padapter)
        pframe = rtw_set_ie(pframe, _SSID_IE_,  pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen));
 
        //supported rate & extended supported rate
+#if 1  // Check if the AP's supported rates are also supported by STA.
+       get_rate_set(padapter, sta_bssrate, &sta_bssrate_len);
+       //DBG_871X("sta_bssrate_len=%d\n", sta_bssrate_len);
+                               
+       //for (i = 0; i < sta_bssrate_len; i++) {
+       //      DBG_871X("sta_bssrate[%d]=%02X\n", i, sta_bssrate[i]);
+       //}
+       for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
+               if (pmlmeinfo->network.SupportedRates[i] == 0) break;
+                       DBG_871X("network.SupportedRates[%d]=%02X\n", i, pmlmeinfo->network.SupportedRates[i]);
+       }
+                                                                                       
+       for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) {
+               if (pmlmeinfo->network.SupportedRates[i] == 0) break;
+                                               
+               // Check if the AP's supported rates are also supported by STA.
+               for (j=0; j < sta_bssrate_len; j++) {
+               // Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP
+                       if ( (pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK) 
+                               == (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) {
+               //DBG_871X("match i = %d, j=%d\n", i, j);
+                               break;
+                       } else {
+               //DBG_871X("not match: %02X != %02X\n", (pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK), (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK));
+                       }
+               }
+               if (j == sta_bssrate_len) {
+                       // the rate is not supported by STA
+                       DBG_871X("%s(): the rate[%d]=%02X is not supported by STA!\n",__FUNCTION__, i, pmlmeinfo->network.SupportedRates[i]);
+               } else {
+               // the rate is supported by STA
+                       bssrate[index++] = pmlmeinfo->network.SupportedRates[i];
+               }
+       }
+       bssrate_len = index;
+       DBG_871X("bssrate_len = %d\n", bssrate_len);
+#else  // Check if the AP's supported rates are also supported by STA.
 #if 0
        get_rate_set(padapter, bssrate, &bssrate_len);
 #else
        for (bssrate_len = 0; bssrate_len < NumRates; bssrate_len++) {
                if (pmlmeinfo->network.SupportedRates[bssrate_len] == 0) break;
+               
+               if (pmlmeinfo->network.SupportedRates[bssrate_len] == 0x2C) // Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP
+                       break;
+               
                bssrate[bssrate_len] = pmlmeinfo->network.SupportedRates[bssrate_len];
        }
 #endif
-
+#endif // Check if the AP's supported rates are also supported by STA.
        if (bssrate_len > 8)
        {
                pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen));
index 6b6e6caae14b4cdf1593ec5b69976f151f59cde8..ff29e0a94223e4238253100bf94ff34240d30670 100755 (executable)
 /* 
  * CONFIG_USE_USB_BUFFER_ALLOC_XX uses Linux USB Buffer alloc API and is for Linux platform only now!
  */
-#define CONFIG_USE_USB_BUFFER_ALLOC_TX 1       // Trade-off: For TX path, improve stability on some platforms, but may cause performance degrade on other platforms.
+//#define CONFIG_USE_USB_BUFFER_ALLOC_TX 1     // Trade-off: For TX path, improve stability on some platforms, but may cause performance degrade on other platforms.
 //#define CONFIG_USE_USB_BUFFER_ALLOC_RX 1     // For RX path
 
 /* 
index 8450b03d6bc6c5941b3e78904d5c4ee1325508f6..1f9ea8bd2cb6bedd054971ec9e324bac21cdb040 100755 (executable)
@@ -47,7 +47,7 @@
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5))
        #include <linux/kref.h>
 #endif
-       #include <linux/smp_lock.h>
+//     #include <linux/smp_lock.h>
        #include <linux/netdevice.h>
        #include <linux/skbuff.h>
        #include <linux/circ_buf.h>
index 50226122c4853ab7a689adbb9b2ce47624c54b0e..0bc5383d2e10da6fa7eb9562d0dec0be000cc8c6 100755 (executable)
@@ -33,7 +33,7 @@
 #include <linux/semaphore.h>
 #endif
 #include <linux/list.h>
-#include <linux/smp_lock.h>
+//#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 #include <asm/atomic.h>
 
index f780da17dc2facf8a83b1d171f0dfed2be3e1847..ad7ff64b2beacd6fed2df7ec32db81d7872bb2b7 100644 (file)
 begin 644 os_dep/linux/ioctl_linux.o
-M?T5,1@$!`0````````````$`*``!``````````````"P:0``````!30`````
+M?T5,1@$!`0````````````$`*``!``````````````#8:0``````!30`````
 M`"@`$0`.`#`P0.)S,._F"0!3XS``0)(>_R^183!`XG,P[^8%`%/C5P!`DA[_
-M+Y%!,$#B<S#OY@4`4^,``."#-P!`DA[_+^$$0"WEX$*0Y0,P`>(#`%/C"@``
-M&@`PH.,,*P'C`C"$YP(0H.,(*P'C`A"$YP,0H..@)P'C`A"$YP-`H.$<``#J
-M`@`1XPD```H`,*#C#"L!XP(PA.<!(*#C"!L!XP$@A.>@%P'C`2"$YP-`H.$0
-M``#J`0`1XPH```H(.P'C`S"4YP,`4^,)``"*`#"@XP@K`>,",(3GH"<!XP(P
+M+Y%!,$#B<S#OY@4`4^,``."#-P!`DA[_+^$$0"WE@$.0Y0,P`>(#`%/C"@``
+M&@`PH.,D*P'C`C"$YP(0H.,@*P'C`A"$YP,0H..X)P'C`A"$YP-`H.$<``#J
+M`@`1XPD```H`,*#C)"L!XP(PA.<!(*#C(!L!XP$@A.>X%P'C`2"$YP-`H.$0
+M``#J`0`1XPH```H@.P'C`S"4YP,`4^,)``"*`#"@XR`K`>,",(3GN"<!XP(P
 MA.<#0*#A`P``Z@0`$>,50.`#````"@!`H.,$`*#A$`"]Z![_+^$``*#C'O\O
-MX>`RD.5L,)/E"``3XP(PH!,`,((5"P``&D``$^,!```:(``3XP(```H!,*#C
-M`#""Y00``.H0`!/C`S"@$P`P@A4`,*`#`#""!0``H.,>_R_A!$`MY>!"D.5L
-M,)3E`0`3XP8```IR-0'CTS"4X0`P8^(`,(+E`#"@XP0PPN4$``#J`#"@XP`P
+MX8`SD.5L,)/E"``3XP(PH!,`,((5"P``&D``$^,!```:(``3XP(```H!,*#C
+M`#""Y00``.H0`!/C`S"@$P`P@A4`,*`#`#""!0``H.,>_R_A!$`MY8!#D.5L
+M,)3E`0`3XP8```J*-0'CTS"4X0`P8^(`,(+E`#"@XP0PPN4$``#J`#"@XP`P
 M@N4$,,+E`3"@XP4PPN4``*#C$`"]Z![_+^$`,-#E``!3XP@```H!`%/A`P``
 M&@@``.H,`(#B`0!3X04```H,,-#E``!3X_G__QH``%/B`0"@$Q[_+^$!`*#C
-M'O\OX>`2D.6I/:#CLS"1X0`P@N4``*#C!`#"Y1[_+^$$0"WEX$*0Y04PTN4`
-M`%/C!```"BHI`.,$-`'C`R"$YP``H.,(``#J`#"2Y0$<0^(J*`#C`@!1X14`
-MX(,!,,.3!"0!DP(PA)<``*"3$`"]Z![_+^'@$I#E!#0!XP,PD><`,(+E``"@
+M'O\OX8`3D.58.@+CLS"1X0`P@N4``*#C!`#"Y1[_+^$$0"WE@$.0Y04PTN4`
+M`%/C!```"BHI`.,<-`'C`R"$YP``H.,(``#J`#"2Y0$<0^(J*`#C`@!1X14`
+MX(,!,,.3'"0!DP(PA)<``*"3$`"]Z![_+^&`$Y#E'#0!XP,PD><`,(+E``"@
 MXP0`PN4>_R_A!S"@XP`P@N4``*#C!`#"Y0$PH.,%,,+E'O\OX0``H.,``(+E
-M!`#"Y0$PH.,%,,+E'O\OX1!`+>D(T$WBX$*0Y0X`D^@`,(WE!`"@X?\_#^,/
-M,$#CU<V@XP_@H.$,\)3G``"@XPC0C>(0@+WH``#@XQ[_+^$``.#C'O\OX0``
-MH.,>_R_A``"@XQ[_+^$``*#C'O\OX0``H.,>_R_A<``MZ>!"D.4"8*#A8#4#
+M!`#"Y0$PH.,%,,+E'O\OX1!`+>D(T$WB@$.0Y0X`D^@`,(WE!`"@X?\_#^,/
+M,$#C:,4#XP_@H.$,\)3G``"@XPC0C>(0@+WH``#@XQ[_+^$``.#C'O\OX0``
+MH.,>_R_A``"@XQ[_+^$``*#C'O\OX0``H.,>_R_A<``MZ8!#D.4"8*#AB#4#
 MXP,0E.<!,'+B`#"@,P``4>,!,(,3``!3XQ5`X!,*```:`%"2Y0(`5>,`0*"#
 M!4&$D`0PMI4$,(25`#``DP`P0),`():5!2&#EP!`H),$`*#A<`"]Z![_+^$`
 M`*#C'O\OX0``H.,>_R_A``"@XQ[_+^$>_R_A'O\OX?!'+>D(T$WB`%"@X1,0
-MH.,'((WB"#4#XP_@H.$#\)#G!S#=Y0,`4^,``%,3`:"@`P*@H!,`8*#C!I"@
-MX3QU`^,`@.#C"P``Z@4`H.$&$*#A!""@X0@PH.$/X*#A!_"5YP%`A.(!#%3C
-M]O__&@%@AN(*`%;A`0``J@E`H.'Q___J"-"-XO"'O>@``*#C'O\OX01`+>7@
-M0I#E;#"4Y0$`$^,'```:`#"@XP(F`^,",,3G`R8#XP(PQ.<$)@/C`C#$YPL`
-M`.IT-0'C`Q#4YW8U`>,#(-3G<C4!X],`E.$#-@/C`P#$YP(V`^,#$,3G!#8#
-MXP,@Q.</(*#C!38#XP,@Q.<V#(3B$`"]Z![_+^%P0"WI`T"@X>!2D.4%`*#A
-M!@"3Z/\_#^,/,$#C/,4#XP_@H.$,\)7G`%"@X00`H.$`$`#C`!!`XP4@H.'^
-M___K``"@XW"`O>CP3RWIJ=]-X@*0H.$#8*#AX+*0Y6H]#^/_/T_C`$"@XRHN
-MC>*S0(+A:#T/X_\_3^.S0(+A(@Z-X@00H.&`(*#C_O__ZR``C>($$*#A`BR@
-MX_[__^L`$)GEM'#9X0W`H.%_/<SC/S##XPA0D^4'0)'@!4#4,`!0H#,``%7C
-M!0``&@8`H.$'(*#A_O__ZP``4.-Q`0`:!@``Z@``5^,$```*!@"@X0<0H.'^
-M___K#0#@XVP!`.H`0*#C#$"-Y1!`C>440(WE'&"-Y1QPC>(`@`#C`(!`XPR@
-MC>($4*#A`P``Z@P`5>,&```*!4"*YP10A>('`*#A"!"@X?[__^L`0%#B]O__
-M&@Q`G>4$`*#A`!``XP`00./^___K``!0XSP``!H+`*#A`!"@XX`@H.,B/HWB
-M_O__ZP$`4.-'`0`:!@"@X0`0H.,$(*#C_O__ZP8`H.$8%9_E!B"@X?[__^L`
-MH*#C#+6?Y0"``.,`@$#C!@"@X0L0H.$&(*#A"C"@X?[__^LB+HWB"E""X`5P
-MH.$`0*#C!@"@X0@0H.$&(*#A`3#7Y/[__^L!0(3B"`!4X_?__QH&`*#AO!2?
-MY08@H.'^___K!@"@X0@0H.$&(*#A"##5Y?[__^L!0(3B`5"%XA``5./V__\:
-M!@"@X8P4G^4&(*#A_O__ZQ"@BN*``%KCVO__&@8`H.'^___KM`#)X0``H.,4
-M`0#J!`"@X0`0`.,`$$#C_O__ZP``4.-!```:$`"=Y0``4.,*`0`*%$"=Y0``
-M5.,'`0`*&%"-X@40H.$0(*#C_O__ZP!PH.$$`*#A!1"@X0H@H./^___K<%#_
-MY@``5>/[```*=W#_YFI-#^/_3T_C`!"@XP`0C>4+`*#A`R"@XRK.C>($,(S@
-M_O__ZP6`H.$',(7@*BZ-XK1`DN$$`%/AZ0``R@L`H.$'$*#A!2"@X2(^C>+^
-M___K!@"@X0`0H.,$(*#C_O__ZP!`H..<4Y_E(GZ-XIBCG^4)``#J!@"@X040
-MH.$&(*#A!##7Y_[__^L&`*#A"A"@X08@H.'^___K`4"$X@@`5.'S__^Z!@"@
-MX?[__^L!`(#BM`#)X0``H./,``#J!`"@X0`0`.,`$$#C_O__ZP``4.,P```:
-M(#"-X@`PC>4+`*#A`!"@XP$@H.$"/*#C_O__ZP``4..Z```*!@"@X0`0H.,$
-M(*#C_O__ZP!`H.,`4`#C`%!`XR!PC>(`H`#C`*!`XP"``.,`@$#C!@"@X040
-MH.$&(*#A!##7Y_[__^L/,`3B#P!3XP0``!H&`*#A"!"@X08@H.'^___K!@``
-MZ@<P!.('`%/C`P``&@8`H.$*$*#A!B"@X?[__^L!0(3B`@Q4X^C__QH&`*#A
-M_O__Z[0`R>$``*#CE0``Z@0`H.$`$`#C`!!`X_[__^L``%#C,```&A!`G>4`
-M`%3CBP``"A1`G>4``%3CB```"FI-#^/_3T_C`!"@XP`0C>4+`*#A`R"@XRK.
-MC>($,(S@_O__ZRHNC>*T0)+A%0!4XWD``-H+`*#A%A"@XP8@H.,B/HWB_O__
-MZP8`H.$`$*#C!""@X_[__^L`4*#CW'&?Y2).C>+8@9_E!@"@X0<0H.$&(*#A
-M!3#4Y_[__^L&`*#A"!"@X08@H.'^___K`5"%X@8`5>/S__\:!@"@X?[__^NT
-M`,GA``"@XUX``.H$`*#A`!``XP`00./^___K``!0XS```!H00)WE``!4XU0`
-M``H40)WE``!4XU$```IJ30_C_T]/XP`0H.,`$(WE"P"@X0,@H.,JSHWB!#",
-MX/[__^LJ+HWBM$"2X0D`5.-"``#:"P"@X0H0H.,$(*#C(CZ-XO[__^L&`*#A
-M`!"@XP0@H./^___K`%"@XP!QG^4B3HWB_("?Y08`H.$'$*#A!B"@X04PU.?^
-M___K!@"@X0@0H.$&(*#A_O__ZP%0A>($`%7C\___&@8`H.'^___KM`#)X0``
-MH.,G``#J!`"@X0`0`.,`$$#C_O__ZP``4.,4```::$T/X_]/3^,+`*#A*CZ-
-MX@00@^#^___K"P"@X?[__^LJSHWBM$"<X0`P9.`&`*#A`!``XP`00.,&(*#A
-M_O__ZP8`H.'^___KM`#)X0``H.,,``#J!@"@X0`0`.,`$$#C!B"@X?[__^L&
-M`*#A_O__Z[0`R>$``*#C`@``Z@T`X.,```#J%0#@XZG?C>+PC[WH%````!P`
-M```P````-````$````!,````\$$MZ0C03>(#@*#AX'*0Y0)@H.$`,*#C!#"-
-MY0`0DN4-(*#A?SW"XS\PP^,(0)/E!%"1X@10U3``0*`S``!4XP,``!H$`(WB
-M!""@X_[__^L"``#J!`"-X@00H./^___K8#4#XP,PE^<!8';B`&"@,P``4^,!
-M8(83``!6XQ5`X!,F```:!$"=Y0``5.,`,-@%!#"-!00PG>4!`%/C"```&IPT
-M`^,#,)?G``!3XQH```H'`*#A"1"@XS/_+^$`0*#C%@``Z@(`4^,(```:G#0#
-MXP,PE^<``%/C#P``"@<`H.$*$*#C,_\OX0!`H.,+``#J`P!3XP@``!J<-`/C
-M`S"7YP``4^,$```*!P"@X0P0H.,S_R_A`$"@XP```.H`0*#C!`"@X0C0C>+P
-M@;WH\$4MZ:G?3>+@HI#E`$"@XPQ`C>400(WE%$"-Y6HM#^/_+T_C*AZ-XK)`
-M@>$<,(WE'&"-X@!P`.,`<$#C#("-X@,``.H,`%3C!@``"@10B.<$0(3B!@"@
-MX0<0H.'^___K`%!0XO;__QH,0)WE!`"@X0`0`.,`$$#C_O__ZP``4.,O```:
-M$`"=Y0``4..]```*%%"=Y0``5>.Z```*&!"-XA`@H./^___K`("@X04`H.'^
-M___KH'"PX0!@H!,B3HT2M```"@0``.H"`%7E`1!5Y?[__^L&`,3G`6"&X@)0
-MA>('`%;A]___.GA0[^9J30_C_T]/XP`0H.,`$(WE"@"@X0,@H.,JSHWB!#",
-MX/[__^L',(7@*AZ-XK1`D>$$`%/AG```B@H`H.$%$*#A=R#_YB(^C>+^___K
-M``!0XY4```J2``#J!`"@X0`0`.,`$$#C_O__ZP``4.,B```:$`"=Y0``4..'
-M```*%%"=Y0``5>.$```*&!"-XA`@H./^___K`("@X04`H.'^___KH'"PX0!@
-MH!,@0(T2?@``"@0``.H"`%7E`1!5Y?[__^L&`,3G`6"&X@)0A>('`%;A]___
-M.B`PC>(`,(WE"@"@X0$0H.-X(._F=S#_YO[__^L``%#C;```"FD``.H$`*#A
-M`!``XP`00./^___K``!0XRP``!H04)WE``!5XUX```H40)WE``!4XUL```H%
-M`*#A_O__ZZ!PL.%;```*!@!7XP!@H),B3HV25P``B@0``.H"`%7E`1!5Y?[_
-M_^L&`,3G`6"&X@)0A>('`%;A]___.FI-#^/_3T_C`!"@XP`0C>4*`*#A`R"@
-MXRK.C>($,(S@_O__ZQ8PA^(J'HWBM$"1X00`4^%```"*"@"@X180H.-W(/_F
-M(CZ-XO[__^L``%#C.0``"C8``.H$`*#A`!``XP`00./^___K``!0XRH``!H0
-M0)WE``!4XRL```H44)WE``!5XR@```H$`*#A_O__ZZ!PL.$H```*!%"@X0!@
-MH.,B3HWB``#5Y0$0U>7^___K!@#$YP%@AN("4(7B!@!7X??__XIJ30_C_T]/
-MXP`0H.,`$(WE"@"@X0,@H.,JSHWB!#",X/[__^L*,(?B*AZ-XK1`D>$$`%/A
-M#P``B@H`H.$*$*#C=R#_YB(^C>+^___K``!0XP@```H%``#J)`"?Y?[__^L`
-M`*#C!```ZA4`X.,"``#J``"@XP```.H-`.#CJ=^-XO"%O>C$````\$`MZ130
-M3>("0*#AX&*0Y0`P`.,`,$#C`%#3Y0``5>,(```:`U"@X0`P`.,`,$#C!0"@
-MX0`0D^40(*#C_O__ZP`PH.,/,,7EM##4X1``4^-2``"*`!"4Y0T@H.%_/<+C
-M/S##XPA0D^400)'B!4#4,`!0H#,``%7C!0``&@T`H.$0(*#C_O__ZP``4.,%
-M```*0@``Z@T`H.$0$*#C_O__ZPU`X.,^``#J!@"@X0T0H.'^___K`$!0XCD`
-M`!H```#C``!`XP`0`.,`$$#C"2"@X_[__^L!`%#C"```&LQ0G^40<-7EF#0#
-MXP-PQN<&`*#A_O__ZQ%0U>5%,@/C`U#&YP!0`.,`4$#C#7"@X04`H.$-$*#A
-M$""@X_[__^L`,*#C#S#%Y0T`H.$`$`#C`!!`XPD@H./^___K`0!0XQ@``!H&
-M`*#A`1"@X_[__^N<-`/C`S"6YP``4^,"```*!@"@X0<0H.,S_R_A`%``XP!0
-M0..8-`/C`R#6YQ`@Q>4`<*#C`W#&YP8`H.'^___K13(#XP,@UN<1(,7E`W#&
-MYP```.H-0.#C!`"@X130C>+P@+WH`````!!`+>E4,@/C`S"0Y_\TP^/_,,/C
-M`0A3XR8```I(,@/C`S#0YP``4^,D```*53(#XP,PT.<!`%/C`P``&B0V`^,#
-M,)#G`0!3XQH```IL,)#E`0`3XQD``!J8,@/C`S"0YP(`4^,5```*D#(#XP,P
-MD.<``%/C$0``&@`P`.,`,$#C`#"3Y8@B`^,"()#G9!"@XY$"`>#3+03C8B!!
-MXY+!@>#)#8#B&`"`XB$3@^#^___K`4"@XP(``.H`0*#C````Z@%`H.,$`*#A
-M$("]Z/!!+>D(T$WB`&"@X0)0H.$#0*#A`P"@X0`0`.,`$$#C!""@X_[__^L`
-M`%#C)P``"K0@U>$$($+B<B#_YK0@Q>$$,(3BX(*6Y0$@0N(!`%+C`P``"@(`
-M4N,`<*`3"```&@,``.H`<-/E,'!'XG=P[^8#``#J``#3Y0$0T^7^___K`'"@
-MX0H`5^,0``"*2#(#XP,PV.<'`%/A#```"@``5^,"(*`31S(#$P,@R!<!```:
-M"`"@X?[__^M(,@/C`W#(YP!P5^(!<*`31C(#XP-PR.<$`*#A`!``XP`00.,$
-M(*#C_O__ZP``4.,I```*M##5X00P0^*T,,7AX%*6Y0@@C>(`,*#C!#`BY00`
-MA.(`$`#C`!!`X_[__^L$,)WE`0!3XQ,``(I%(@/C`C#%YP$@H.-(,@/C`R#%
-MYP`P`.,`,$#C`#"3Y8@B`^,"()7G9!"@XY$"`>#3+03C8B!!XY(!@>#)#87B
-M&`"`XB$3@^#^___K!P``Z@(`4^,%```:!0"@X?[__^L``%#C`""@$T@R`Q,#
-M(,47``"@XPC0C>+P@;WH$$`MZ>`"D.4&`)/H_O__ZP``H.,0@+WH\$$MZ1#0
-M3>+@8I#E`$"2Y71P_^946.?G!#"2Y0PPC>4D3*#A<4!$X@X`5.,$\9^7Q0``
-MZO04``#0%P``2!4``-`7``!D%0``B!4``-`7``#0%P``T!<``-`7``#0%P``
-MT!<``-`7``#0%P``R!4```(`5>,(```*!`!5XPL```H!`%7CL```&@8`H.$'
-M$*#A<R#OYO[__^NK``#J!@"@X0<0H.%S(/_F_O__ZZ8``.H&`*#A!Q"@X0,@
-MH.'^___KH0``Z@8`H.$'$*#A`"#@XSC%`^,/X*#A#/"6YYH``.H`,(WE!@"@
-MX040H.$'(*#A`##@X]7-H.,/X*#A#/"6YY$``.H``%7C`""@`W`U`0,#(,8'
-MC```"@$`5>.*```:`2"@XW`U`>,#(,;G#$"=Y60`5.-D0*`C<34!XP-`QN>!
-M``#J#`!5XT<```H&``"*!@!5XQ0```H)`%7C(@``"@4`5>-X```:"@``ZMT`
-M5>-'```*`@``BA$`5>-R```:0```ZNX`5>-0```*_0!5XVT``!IC``#J5PV&
-MXA``@.+@$(;B_O__ZV<``.H+0(WB!@"@X100H.,$(*#A"#4#XP_@H.$#\);G
-M#W`'X@MPS>4&`*#A%!"@XP0@H.$$-0/C#^"@X0/PEN=7``#J_O__ZPT@H.%_
-M/<+C/S##XP0@D^4!((+B!""#Y5>-AN(@@(CB`'"@XZ]?A^*%48;@`$"8Y0``
-M`.H`0)3E!0"@X000H.'^___K``!0X_G__PH!<(?B"("(XB``5^/Q__\:#2"@
-MX7\]PN,_,,/C!""3Y0$@0N($((/E_O__ZS<``.H&`*#A!A"@XPP@C>(0-0/C
-M#^"@X0/PEN<P``#J*R8#XP(PQN<M``#J``!3XP(``!H&`*#A_O__ZR@``.H!
-M`%/C`@``&@8`H.'^___K(P``Z@(`4^,A```:!@"@X?[__^L>``#J#P!3XP8`
-M`!H&`*#A!Q"@XPL@C>(,-0/C#^"@X0/PEN<5``#J!@"@X0<0H.,,((WB$#4#
-MXP_@H.$#\);G!@"@X0<0H.,+((WB##4#XP_@H.$#\);G"```ZG=P[^8&`*#A
-MQ1Z@XP<@H.'^___K!@"@X5@<`.,'(*#A_O__ZP``H.,0T(WB\(&]Z!!`+>G@
-M0I#E`!#2Y445Q.4$`*#A_O__ZP$`4.,``.`3``"@`Q"`O>CP3RWI/-!-XN!2
-MD.5@-0/C`S"5YP*0H.$!('+B`""@,P``4^,",*`!`3""$P``4^,`0*`#'F"@
-M`P4```J+``#J!@"@X?[__^L!0(3B90!4XP(```IL,)7E(@T3X_?__QH`(*#C
-MMB#)X;0PV>$?`%/C?@``F@`0F>4-(*#A?SW"XS\PP^,(8)/E($"1X@9`U#``
-M8*`S``!6XP4``!H,`(WB(""@X_[__^L``%#C!0``"FX``.H,`(WB(!"@X_[_
-M_^L50.#C;```ZO[__^L-(*#A?SW"XS\PP^,$()/E`2""X@0@@^6$0(7BA*"5
-MY0"PH.,L@(WB``.-Z`20H.$)`*#A"A"@X?[__^L!`%#C/```"@M`H.$,4(WB
-M``#5Y;;Y_^L`<%#B$```N@$`]>6R^?_K`&!0X@P``+H!4(7B!V*&X01@R.<$
-M`%3C`P``R@`PU>4Z`%/C!```&@%0A>(!0(3B!@!4X^O__QI&``#J#2"@X7\]
-MPN,_,,/C!""3Y0$@0N($((/E_O__ZQ5`X.,Z``#JH&"%XI`@E>4&`*#A-!"-
-MX@P@0N+^___K``!0XP4```HT0)WE``!4XP20G14!,*`3MC#)$0\``!J0()7E
-M!@"@X300C>(,($+B_O__ZP``4.,%```*-$"=Y0``5.,$D)T5`B"@$[8@R1$"
-M```:`*":Y;W__^H$D)WE#2"@X7\]PN,_,,/C!""3Y0$@0N($((/E_O__Z[0P
-MV>$A`%/C$0``F@``F>4@`(#B#2"@X7\]PN,_,,/C"%"3Y0%`D.(%0-0P`%"@
-M,P``5>,$```:!A")X@$@H./^___K``!0XP$```H50.#C````Z@!`H.,$`*#A
-M/-"-XO"/O>@*4*#A``"=Y2`0BN(&(*#C_O__ZP$`4./5__\:N?__ZO!'+>D(
-MT$WB`D"@X>!BD.6T4-+A``!5XXT```H`,)+E``!3XXH```JVD-+A!7"@X04`
-MH.'^___K`(!0X@M`X`.$```*`!"4Y0T@H.%_/<+C/S##XPB@D^4'4)'@"E#5
-M,`"@H#,``%KC!0``&@@`H.$'(*#A_O__ZP``4.-X```:!@``Z@``5^,$```*
-M"`"@X0<0H.'^___K#4#@XW,``.H(4*#A`#"8Y2(`4^,50."#;@``B@A0B.(&
-M`%/C-@``"@0``(H"`%/C!P``"@,`4^-*```:&@``Z@<`4^,W```*'P!3XT4`
-M`!H^``#J!#"5Y0(`4^,(```*!`!3XPL```H!`%/C/0``&@8`H.$`$)7E_O__
-MZP@`A>4X``#J!@"@X0`0E>7^___K"`"%Y3,``.H&`*#A`!"5Y?[__^L(`(7E
-M+@``Z@0PE>4"`%/C"```"@0`4^,+```*`0!3XR<``!H&`*#A`!"5Y0@@U>7^
-M___K(@``Z@8`H.$`$)7EN"#5X?[__^L=``#J!@"@X0`0E>4(()7E_O__ZQ@`
-M`.H&`*#A`!#5Y00@U>4`,.#C/,4#XP_@H.$,\);G"`"%Y0\``.H`$-7E!"#5
-MY0@PE>4`,(WE!@"@X0`PX./5S:#C#^"@X0SPEN<%``#J!@"@X2@0H.,`(*#C
-M!#4#XP_@H.$#\);G>9#OY@``6>,7```:``"4Y0T@H.%_/<+C/S##XPA0D^4'
-M0)#@!4#4,`!0H#,``%7C!T"@$0,``!H($*#A!R"@X?[__^L`0*#A``!4XP8`
-M``H#``#J%4#@XP0`H.$(T(WB\(>]Z`U`X.,```#J`$"@XP@`H.$'$*#A_O__
-MZ_7__^IP0"WI`T"@X>`"D.4`$)/E_O__ZP!0H.$$`*#A`!``XP`00.,%(*#A
-M_O__ZP``H.-P@+WH\$<MZ1#03>+@4I#E`V"@X0`PH.,(,(WEO##-X0`PC>6T
-M,,WA#0"@X080AN(&(*#C_O__ZP`PEN4!`%/C*P``&@T`H.$($(WB!B"@X_[_
-M_^L!`%#C40``"@!`H.,-<*#A!H"@XW20[^8$H*#A!`.%X"8,@.()`(#B#1"@
-MX0@@H.'^___K`0!0XP\``!H$HZ#A"@"%X"8,@.(/`(#B%!"&XA`@H./^___K
-M"J"%X":LBN((H(KB`4"@XP!`RN4$D(G@"#H"XP.0Q><W``#J`4"$XA``5./B
-M__\:-@``Z@`@H.,(.@+C`R#%YP%`H.,N``#J`@!3XQT``!H`0*#C#6"@X09P
-MH.,$@*#A!`.%X"8,@.()`(#B#1"@X0<@H.'^___K`0!0XPT``!H$@Z#A"`"%
-MX"8,@.()`(#B`!"@XP8@H./^___K"%"%X"9<A>((4(7B`#"@XP`PQ>4!0*#C
-M$@``Z@%`A.(0`%3CY?__&@T``.H#`%/C"0``&B8,A>((`(#B`!"@XP$KH./^
-M___K`""@XP@Z`N,#(,7G`4"@XP(``.H`0*#C````Z@%`H.,$`*#A$-"-XO"'
-MO>@(2@+C!`#5YP`#A>`F#(#B"0"`X@T0H.$&(*#C_O__ZP0`U><``X7@)@R`
-MX@\`@.(4$(;B$""@X_[__^L$,-7G`S.%X"8\@^((,(/B`2"@XP`@P^4$,-7G
-M`C"#X',P[^8$,,7G$`!3X^#__QJL___J<$`MZ0)`H.'@8I#E;""6Y0$`$N,'
-M```:0``2XP4``!H``*#CM`#$X;8PU.$".8/CMC#$X7"`O>@&4-3E``!5XP0`
-M``H$`%7C%0#@@P%019("``":<("]Z*@G`>,"4);G`1"%XG$0_^:V$,3A#"L!
-MXP(@EN<&`%+C`O&?ES4``.HX(```)"```.`@```D(```R"```.`@``#((```
-M``"@X[0`Q.$"&8'CMA#$X7"`O>A?+H7B"B""X@(AAN"T(-+AM"#$X0``4N,7
-M```*!1*&X%]>A>(*4(7B!5&&X`,`H.%>'8'B+!"!X@0@E>7^___KMB#4X;8@
-MQ.$(.P'C`S"6YP``4^,"*H(#MB#$`0``H`-P@+T(`0!3XP``H!,!*8(#MB#$
-M`0``H`-P@+WH``"@X[0`Q.$"&8'CMA#$X7"`O>@0,*#CM##$X0H;@>.V$,3A
-M``"@XW"`O>@``*#CM`#$X0(9@>.V$,3A<("]Z!!`+>D``%/B!P``"@[`H..T
-MP,+A`3"@X[8PPN$`$`#C`!!`XPP@H.'^___K``"@XQ"`O>AP0"WI`E"@X>!"
-MD.5L()3E`0`2XP(``!I``!+C`$#@`P@```KH8)3EM&#%X0,`H.'L$(3B!B"@
-MX?[__^L!,*#CMC#%X0!`H.,$`*#A<("]Z'!`+>G@4I#E`D"@X0$PH..R,,3@
-M!`"@X0`0H.,&(*#C_O__ZVPPE>4!`!/C`P``&D``$^,!```:$``3XP0```H$
-M`*#AX!"%X@8@H./^___K`P``Z@0`H.$`$*#C!B"@X_[__^L``*#C<("]Z/!!
-M+>D@T$WB`F"@X0-PH.'@0I#E!`"-X@`0H.,<(*#C_O__Z[8PUN$""1/C#0``
-M"@$@H.,,.P'C`R"$YP`PH..D)P'C`C"$Y_PG`>,",(3GH"<!XP(PA.<(*P'C
-M`C"$YP-`H.%N``#J_U`3X@4```H$`%7C%0#@@P%019(!@*"3`P``FF<``.JH
-M)P'C`E"4YP"`H.,""A/C"P``"@`PH.,,*P'C`C"$YZ`G`>,",(3GI"<!XP(P
-MA.?\)P'C`C"$YP@K`>,",(3G&0``Z@$)$^,,```*`""@XPP[`>,#((3G`3"@
-MXZ`G`>,",(3GI"<!XP(PA.?\)P'C`C"$YP@K`>,",(3G"@``Z@`PH.,,*P'C
-M`C"$YZ`G`>,",(3GI"<!XP(PA.?\)P'C`C"$YP@K`>,",(3G"%"-Y;0PUN$`
-M`%/C!@``"@4`4^,%,*"3#3"@@PPPC>4,,(/B!#"-Y1T``.H`,*#C##"-Y0$`
-M6.,9```:J#<!XP-0A.=?7H7B"E"%X@51A.`$,)7E!0!3XP(```H-`%/C"@``
-M&@0``.H!(*#CI#<!XP,@A.<`0*#C'```Z@4@H..D-P'C`R"$YP!`H.,7``#J
-M`#"@XZ0G`>,",(3G`T"@X1(``.H(,)WE`C&#XP@PC>4$4(WB#`"%X@<0H.$,
-M()WE_O__ZP0`H.$%$*#A_O__ZP``4.,$```:F#(#XP,PE.<``%/C7D#@`P``
-M``H`0*#C!`"@X2#0C>+P@;WH\$<MZ0%`H.'@8I#E`#"@XR`P@>4;,,'EOC+1
-MX3`P@^("`%/AS```B@0PD>4!`'/CR0``&K@@T>'_/P_C`P!2X<4``!HD,-'E
-M`P!3X\(``(I>?8;B('"'X@Q0@>(%`*#A`!``XP`00./^___K``!0XT<``!H`
-M(*#C##L!XP,@AN<!,*#CI"<!XP(PAN=8((+B`C"&YR2`U.6^4M3A!`!8XQ5`
-MX(.O``"*``!5XZH```H%`%7C!:"@DPV@H(,,D(KB"0"@X?[__^L`4%#BI```
-M"@4`H.$`$*#C'""@X_[__^L(H(7E`)"%Y0T`6N,%,*`#I"<!`P(PA@=8((("
-M`C"&!P(QB.,$,(7E#*"%X@H`H.$P$(3B"""5Y?[__^L<,-3E``!3XP4```H&
-M`*#A!1"@X?[__^L``%#CC@``"HL``.H#`%CCBP``BJ@'`>,(`H#@``"&X`0`
-M@.(*$*#A"""5Y?[__^M?/HCB"C"#X@,QAN`(()7E!""#Y08`H.$'$*#A"""@
-MX0`PH./^___K`$"@XWD``.J@-P'C`S"6YP(`4^-O```:;""6Y0@P`.,!,$#C
-M`S`"X```4^-I```*5PV&XA``@.+@$(;B_O__ZP"`4.)-```*!0"@X:P1G^7^
-M___K``!0XP`PH!/H,(@5##L!XP,PEN<&`%/C!`!3$Z0W`0,#,)8'[#"(!1PP
-MU.4!`%/C&P``&C!PA.*^(M3A$0Z(X@<0H.$0`%+C$""@(_[__^L%`*#A5!&?
-MY?[__^L``%#C"@``&O``B.(0$(?B"""@X_[__^L!#(CB&!"'X@@@H./^___K
-M`""@X_DZ`>,#(,;G!@"@X0@0H.$!(*#C_O__ZR$``.HD`-3E!@V`X@`"AN`P
-M@(3BOB+4X00`@.(($*#A$`!2XQ`@H"/^___K)`#4Y6$/@.(``H;@!`"`XA`0
-MB.(((*#C_O__ZR0`U.5B#X#B``*&X`0`@.(8$(CB"""@X_[__^L!,*#C^"H!
-MXP(PQN<D$-3EOB]"X@(0AN<&`*#A!Q"@X20@U.7^___K!@"@X?[__^L`0%#B
-M$0``"@4`H.%D$)_E_O__ZP``4.,`,*`3Z#"$%0P[`>,#,);G!@!3XP0`4Q,&
-M```:I#<!XP,PEN?L,(3E`$"@XP(``.H50.#C````Z@!`H.,$`*#A\(>]Z`!`
-MH.,```#J7D#@XP4`H.$)$*#A_O__Z_;__^H4`0``'`$``/!'+>D`D*#A`J"@
-MX0-@H.&V<M/A0'"'X@<`H.'^___K`$"@X0"`H.$``%#C0@``"@`0H.,'(*#A
-M_O__ZP0`H.$#,*#C!#"`Y/\0H.,&(*#C_O__Z[0RUN$#`%/C`_&?ES4``.HH
-M*```'"@``#0H``!`*````%``XP!00.,'``#J`%``XP!00.,$``#J`%``XP!0
-M0.,!``#J`%``XP!00.,,`(CB!1"@X1`@H./^___K`#"6Y00`$^,`,*`3'##(
-M%0`PEN4(`!/C`3"@$QPPR!4&,-KE`3!#XB0PR.4`,);E`@`3XP,```HE`(CB
-M#!"&X@@@H./^___KMC+6X0``4^,$```*OC+(X3``B.(H$(;BMB+6X?[__^L)
-M`*#A"!"@X0<@H.'0_O_K`%"@X00`H.$'$*#A_O__ZP```.H`4.#C!0"@X?"'
-MO>AP0"WI`%"@X0)`H.'@8I#EMC#2X0,ZH.$C.J#A"@!3XP/QGY<*``#J_"D`
-M`/PI``#\*0``_"D``$PI``!T*0``Q"D``/PI``#\*0``1"D``/PI``!>0.#C
-M+```Z@`PDN4``%/C`2"@$R8\H!,#(,87`$"@$P!`H`,F/*`#`T#&!R(``.H,
-M.P'C`S"6YP``4^,=```*`#"2Y0``4^,:```*`2"@XPP[`>,#((;G`$"@XZ0W
-M`>,#0(;G_#<!XP-`AN>@-P'C`T"&YP@[`>,#0(;G#@``ZFPPEN4!`!/C!0``
-M"@8`H.'^___K!@"@X?[__^L&`*#A_O__ZP4`H.$`$)3EDO7_ZP!`H.$```#J
-M`$"@XP0`H.%P@+WH\$\MZ1303>(`8*#A`D"@X0`PH.,,,(WE"#"-Y0%0H.$#
-M`%'A`!"@$P$0H`.``%+C`3"@D0$P@8,``%/C!@``"@`@H./P.`'C`R#`YP(`
-M4>$"0*`1%4#@`\8``.H``%+C`$"@`\,```H$L*#A!`"@X?[__^L`<%#B"T#@
-M`[T```H'`*#A!1"@X0L@H.'^___K`P!4XP!`X)/#``":!%"@X0<`H.$$$*#A
-M#""-X@@PC>+^___K`0!0XP4``!H"(*#CH#<!XP,@AN<$(*#C"#L!XP,@AN<'
-M`*#A!1"@X0P@C>((,(WB_O__ZP$`4.,%```:`B"@XZ`W`>,#((;G!R"@XP@[
-M`>,#((;G#%"=Y0%01>(/`%7C!?&?ES$``.ID*P``@"L``.PK``#4*P``["L`
-M`.PK``#L*P``G"L``.PK``#L*P``["L``.PK``#L*P``["L``.PK``"X*P``
-M`""@X_PW`>,#((;G`2"@XPP[`>,#((;G&@``Z@$@H./\-P'C`R"&YP`@H.,,
-M.P'C`R"&YQ,``.H"(*#C_#<!XP,@AN<$(*#C##L!XP,@AN<,``#J!""@X_PW
-M`>,#((;G!B"@XPP[`>,#((;G!0``Z@4@H./\-P'C`R"&YP`@H.,,.P'C`R"&
-MYPA0G>4!4$7B#P!5XP7QGY<R``#J0"P``%PL``#,+```L"P``,PL``#,+```
-MS"P``'@L``#,+```S"P``,PL``#,+```S"P``,PL``#,+```E"P````@H..D
-M-P'C`R"&YP$@H.,,.P'C`R"&YTL``.H!(*#CI#<!XP,@AN<`(*#C##L!XP,@
-MAN=$``#J`B"@XZ0W`>,#((;G!""@XPP[`>,#((;G/0``Z@0@H..D-P'C`R"&
-MYP8@H.,,.P'C`R"&YS8``.H%(*#CI#<!XP,@AN<`(*#C##L!XP,@AN<O``#J
-M`""@X_`X`>,#(,;G`#``XP`P0.,`,)/E!#"-Y2X``.H%@*#A!:"'X``PVN7=
-M`%/C%@``&@(`A>(``(?@!!"-X@0@H./^___K`0!0XP\``!H!0*#C"H"@X00@
-MVN<"((+B`@Q2XP(LH*/T.@'C`R"&YV,-AN(Q`(#B"A"@X?[__^OP.`'C`T#&
-MYP!`H.,5``#J"("'X`DPV.<",(/B`U"%X'50_^8%`%3AW/__B@!`H.,,``#J
-M!`"@X130C>+PC[WH`""@X_`X`>,#(,;G`#``XP`P0.,`,)/E!#"-Y0!0H.,!
-MD*#CS?__Z@<`H.$+$*#A_O__Z^[__^H00"WIX`*0Y0,0H.&T(-+A"___ZQ"`
-MO>CP12WI#-!-X@)0H.$`,*#C!#"-Y>!BD.6R,,WA`3#-Y6PPEN4!`!/C`@``
-M&D``$^,``.`#60``"E`QEN46#H;B+1"@XP0@C>(,,$/B_O__ZP!P4.(0```*
-M!$"=Y0``5.,-```*!T"@X0(`C>(%$(?B`B"@X_[__^L",/3E`2#4Y0(T@^'3
-MH.#G8``3XP!PH`,!<*`3`8"@XP(``.H`<*#C!Z"@X0>`H.$\,=;E`2!#XG(@
-M[^;]`%+C`$"@@PP``(H&(*#A`$"@XP0`H.%_,`/B!`!3X0-`H"$$`,7E/3'2
-MY0$@@N(!$$/B<1#OYOT`4>/U__^:`0!8XR,``!H&`*#A$Q"@XP$@C>((-0/C
-M#^"@X0/PEN<!0-WE`P!4XPD``!H``%KC`P``"@``5^.6<*`3AW"@`PT``.H`
-M`%?C2'"@$T%PH`,)``#J``!:XP0```H.,0#C``!7XP-PH`%+?Z`3`@``Z@``
-M5^.0<*`3@G"@`X=PH.$@,0KC!S!`XY,'`^``,(7E``"@XP0``.H@,0KC!S!`
-MXY,$`^``,(7E``"@XPS0C>+PA;WH<$`MZ2#03>+@8I#E`$"2Y03@TN4-P*#A
-M,#&?Y0\`D^@'`*SH`##,Y0$`=.,P```*I$*@X<4Z!>-\.D#CDR2#X*,SH.%N
-M`%/C!5"@`RD```H/``"*-P!3XP)0H`,E```*!0``B@H`4^,`4*`#(0``"A0`
-M4^,>```:%0``ZCP`4^,#4*`#&P``"EH`4^,8```:$0``ZO``4^,(4*`#%0``
-M"@4``(IX`%/C!E"@`Q$```JT`%/C#@``&@D``.I:#U/C"5"@`PL```H>#E/C
-M"```&@4``.H!4*#C!@``Z@10H.,$``#J!U"@XP(``.H*4*#C````Z@M0H.,`
-M0*#C#0"@X1`0C>(`P.#C!##0YP4`4^$$P,$7`@``&@0PP><``%[C`@``"@%`
-MA.(-`%3C]?__&@8`H.$0$(WB_O__ZP$`4.,``*`#``#@$R#0C>)P@+WH!```
-M`/!%+>DLT$WB`E"@X0-@H.'@0I#E!`"@X?[__^L``%#C2```"J`U`^,#,)3G
-M``!3XT0```JT@-7A(`!8XP9`X(-#``"*;#"4Y1``$^,]```:"#L!XP.@E.>V
-M,-7A``!3XSH```H``%CC.```"B``6.,@@*`C!%"-X@4`H.$`$*#C)""@X_[_
-M_^LH<(WB)(`GY00`A>(&$*#A"""@X?[__^N$8(3BA#"4Y7@PA.4$<(?B!@"@
-MX7@0E.7^___K`0!0XQ@```IX4)3E!0"@X2PPD.1X,(3E!Q"@X00@G>7^___K
-M`0!0X_'__QHH()7E!#"=Y0,`4N'M__\:;#"4Y2``$^,#```*>""5Y3@QE.4#
-M`%+AYO__&@0`H.%X$)7E_O__ZP``4.,'```*!`"@X0H0H.'^___K!`"@X000
-MC>+^___K``!0XP$``!H`0.#C````Z@!`H.,$`*#A+-"-XO"%O>CP0"WI#-!-
-MX@)@H.'@0I#E`#"@XP0PC>5L,)3E00`3XT\```I0,93E%@Z$XBT0H.,$((WB
-M##!#XO[__^L``%#C`'"@`P(```H$4)WE`'!5X@%PH!-/7X3B!0"@X?[__^L!
-M`%#C#0``&@$`5^,%```:!@"@X1`0H.,`(`#C`"!`X_[__^L[``#J!@"@X1`0
-MH.,`(`#C`"!`X_[__^LU``#J!0"@X?[__^L!`%#C#0``&@$`5^,%```:!@"@
-MX1`0H.,`(`#C`"!`X_[__^LI``#J!@"@X1`0H.,`(`#C`"!`X_[__^LC``#J
-M)#&4Y0X`4^,-``":`0!7XP4``!H&`*#A$!"@XP`@`.,`($#C_O__ZQ@``.H&
-M`*#A$!"@XP`@`.,`($#C_O__ZQ(``.H!`%?C!0``&@8`H.$0$*#C`"``XP`@
-M0./^___K"@``Z@8`H.$0$*#C`"``XP`@0./^___K!```Z@(`H.$0$*#C`"``
-MXP`@0./^___K``"@XPS0C>+P@+WH^$\MZ0-PH.'@0I#ECC^@X[0PPN$'`*#A
-M`!"@XP,@H.'^___K0#L$XTPP0.,`,(?E9#"@XRPPQ^4M,,?E+C#'Y0<PH.,O
-M,,?E7""@XS`@Q^5-(.#C,2#'Y0!0H.,R4,?E,S#'Y00PH.,T,,?E`#``XP`P
-M0.,`8)/E.&"'Y01@D^4\8(?E"&"3Y4!@A^4,8)/E1&"'Y0$\H./`,(?E*CD`
-MX\0PA^6\7<?A%C"@XQ@QQ^40,*#C&3''Y05@H.$*H*#C!)"@XZ"V".,!L$#C
-MG#?4Y0``4^,*```*)H"&XHB!A^`*,,CGG`?4Y?[__^N;``#@"0"(YP$PH..X
-M,,CA`6"&XG9@_^8@`%;C`P``"@%0A>(,0(3B)@!5X^O__QH3/J#CLV"'X3)A
-MQ^4/,*#C-#*'Y3\PH.,/,,?E``"@X_B/O>AP0"WI`E"@X>!"D.5L,)3E`0`3
-MXPH```HD`93E_O__ZZ`V".,!,$#CDP`#X``PA>4!,*#CM##%X20QE.4&,,7E
-M"0``ZI8'U.7^___KH#8(XP$P0..3``/@`#"%Y0$PH..T,,7AEC?4Y08PQ>4`
-M`*#C<("]Z/!/+>G%WTWB`K"@X0-0H.$`,*#C]#*-Y0(LC>*R.\+A%3L(X_\_
-M3^.^/\+A`3"@XP,LC>*P,,+A`PR-X@(`@.(@$(OB!B"@X_[__^L48(7B.#.=
-MY08`4^$+``":,4Z-XA0@H..T(63A!0"@X000H.$$(*#C_O__ZP0`A>($$(3B
-M$""@X_[__^L&4*#A*`"+XO[__^L``%#C(```"AL["./_/T_C`BR-XKX_PN$!
-M,*#C`RR-XK8PPN&X<MOA(`!7XR!PH".T<,+A"'"'X@=`A>`X,YWE!`!3X1``
-M`)HQ;HWBM'%FX01PH.,%`*#A!A"@X0<@H.'^___K!P"%X`@0AN('(*#A_O__
-MZP@`A>(L$(OB`SR-XK0@T^'^___K````Z@5`H.&@((OB"""-Y9`PF^4"`*#A
-M+1"@X[TOC>(,,$/B_O__ZP!@4.(4```*]%*=Y0``5>,1```*!E"@X2L.C>("
-M`(#B!1"&X@(@H./^___K`C#UY0$@U>4"-(/ATR#@YR0@C>5@`!/C`#"@`P$P
-MH!,4,(WE`2"@XQ`@C>4#``#J`#"@XQ0PC>4D,(WE$#"-Y0$["./_/T_C`BR-
-MXKX_PN%\4(OB!0"@X?[__^L!`%#C#@``&A`PG>4!`%/C!0``&@,,C>(0$*#C
-M`"``XP`@0./^___K.```Z@,,C>(0$*#C`"``XP`@0./^___K,@``Z@4`H.'^
-M___K`0!0XPX``!H0()WE`0!2XP4``!H##(WB$!"@XP`@`.,`($#C_O__ZR4`
-M`.H##(WB$!"@XP`@`.,`($#C_O__ZQ\``.ID,)OE#@!3XPX``)H0,)WE`0!3
-MXP4``!H##(WB$!"@XP`@`.,`($#C_O__ZQ,``.H##(WB$!"@XP`@`.,`($#C
-M_O__ZPT``.H0()WE`0!2XP4``!H##(WB$!"@XP`@`.,`($#C_O__ZP0``.H#
-M#(WB$!"@XP`@`.,`($#C_O__ZQ1@A.(X,YWE!@!3X0L``)HQ7HWB%""@X[0A
-M9>$$`*#A!1"@X00@H./^___K!`"$X@00A>(0(*#C_O__ZP9`H.$'.PCC_S]/
-MXP(LC>*^/\+AE#"+X@PPC>4#`*#A_O__ZP`0H.&^#XWB`@"`X@(@H./^___K
-M`BR-XKH_TN$#`!/C%0``"@$`$^,#,*`3`#.-%0$PH`,`,XT%")"$XC@SG>4)
-M`%/A#```FC%>C>(((*#CM"%EX01@H.,$`*#A!1"@X08@H.'^___K!@"$X`80
-MA>`&(*#A_O__ZP```.H$D*#A9#";Y0``4^,!,*`#9#"+!04["./_/T_C`BR-
-MXKX_PN%D`)OE_O__ZZ`V".,!,$#CDP`#X``SC>4!,*#C`RR-XK0PPN%D,)OE
-M!C/-Y0Q0B>(X,YWE!0!3X0L``)HQ3HWB#""@X[0A9.$)`*#A!!"@X00@H./^
-M___K!`")X@00A.(((*#C_O__ZP60H.$K.PCC_S]/XP(LC>*^/\+AND_2X1``
-M%.,".Z`3`RR-$K8PPA$".:`#`RR-`K8PP@$`,*#C`RR-XK0PPN$(4(GB.#.=
-MY04`4^$1``":,4Z-X@@@H..T(63A!&"@XPD`H.$$$*#A!B"@X?[__^L&`(G@
-M"!"$X@8@H.'^___K!0"@X2P0B^(#/(WBM"#3X?[__^L%D*#AK8^-X@@`H.%`
-M$*#C`"``XP`@0./^___K?"#;Y0``4N,`<*`#(P``"JU/C>(`0(3@"U"@X0!P
-MH.-`@(CB`#``XP`P0.,8,(WE`#``XP-@H.$`8$#C`*``XP"@0.,<D(WE(+"-
-MY1BPG>4&D*#A?V`"X@<`5N$&<*`A"!!DX*8PH.$!`!+C"2"@`0L@H!$`((WE
-M!`"@X0H@H.'^___K?2#5Y0%0A>(``%+C`$"$$.[__QH<D)WE(+"=Y1`@G>4!
-M`%+C+P``&@(LC>*R.]+A`@D3XPP```HD,)WE``!3XP0```H.<0#C%""=Y0``
-M4N-+?Z`3(@``ZA0PG>4``%/CD'"@$X)PH`,=``#J@``3XPH```HD()WE``!2
-MXP,```H4,)WE``!3XQ0``!H/``#J%""=Y0``4N,.```:"0``ZB0PG>4``%/C
-M`P``"A0@G>4``%+C"0``&@0``.H4,)WE``!3XP,``!I!<*#C!```ZH=PH.,"
-M``#J2'"@XP```.J6<*#CAW"@X2$["./_/T_C`BR-XKX_PN$`,*#C!3/-Y00S
-MS>4@,0KC!S!`XY,'`^``,XWE#%")XC@SG>4%`%/A"P``FC%.C>(,(*#CM"%D
-MX0D`H.$$$*#A!""@X_[__^L$`(GB!!"$X@@@H./^___K!9"@X0`PH.,"+(WB
-ML#O"X;PZPN&0$)OE2S^-X@`PC>4K/HWB!#"-Y0P`G>4L((WBJS^-XO[__^L"
-M/(WBL$O3X0``5.-A```*BT^-X@0`H.$`$*#C@""@X_[__^L`,`#C`#!`XP,`
-MD^@#`(3H`BR-XK!+TN$``%3C$```"B-NC>(#8(;B`$"@XP!P`.,`<$#C2X^-
-MX@10H.$&`*#A!Q"@X04@V.?^___K`&"&X`%0A>("/(WBL$O3X04`5.'U__^*
-MOP^-X@`0H.,4(*#C_O__ZP(\"./_/T_C`BR-XKX_PN&+#XWB_O__ZW``_^8#
-M/(WBM`##X0A0@.(%8(G@.".=Y08`4N$0``":,4Z-XK119.$$4*#C"0"@X000
-MH.$%(*#A_O__ZP4`B>`($(3B!2"@X?[__^L(`(GBBQ^-X@,\C>*T(-/A_O__
-MZP:0H.&_#XWB`!"@XQ0@H./^___K!3P(X_\_3^,"+(WBOC_"X;!;TN$#/(WB
-MM%##X0A0A>(%8(G@.".=Y08`4N$0``":,4Z-XK119.$$4*#C"0"@X000H.$%
-M(*#A_O__ZP4`B>`($(3B!2"@X?[__^L(`(GB2Q^-X@,\C>*T(-/A_O__ZP:0
-MH.$"+(WBO$K2X0``5.-A```*BT^-X@0`H.$`$*#C@""@X_[__^L`,`#C`#!`
-MXP,`D^@#`(3H`CR-XKQ*T^$``%3C$```"B-NC>(#8(;B`$"@XP!P`.,`<$#C
-M+("-X@10H.$&`*#A!Q"@X04@V.?^___K`&"&X`%0A>("+(WBO$K2X04`5.'U
-M__^*OP^-X@`0H.,4(*#C_O__ZP(\"./_/T_C`BR-XKX_PN&+#XWB_O__ZW``
-M_^8#/(WBM`##X0A0@.(%8(G@.".=Y08`4N$0``":,4Z-XK119.$$4*#C"0"@
-MX000H.$%(*#A_O__ZP4`B>`($(3B!2"@X?[__^L(`(GBBQ^-X@,\C>*T(-/A
-M_O__ZP:0H.&_#XWB`!"@XQ0@H./^___K!3P(X_\_3^,"+(WBOC_"X;Q:TN$#
-M/(WBM%##X0A0A>(%8(G@.".=Y08`4N$0``":,4Z-XK119.$$4*#C"0"@X000
-MH.$%(*#A_O__ZP4`B>`($(3B!2"@X?[__^L(`(GB+!"-X@,\C>*T(-/A_O__
-MZP:0H.$`,*#CK#*-Y9"`F^4,@$CB`P!8X0`PH-,!,*##"""=Y0``4N,``%@3
-M.P``V@``4^,Y```*`$"@XZNOC>(%/`CC_S]/XPPPC>6_+XWB""""XA`@C>4$
-M4*#A%+"-Y0BPH.$(@)WE!7"@X05@B.`&`*#A"A"@X?[__^L``%#C'P``"JQ"
-MG>4"`%3C'```F@PPG>4"+(WBOC_"X;PZTN$#+(WBM##"X0@P@^((,(WE`T")
-MX#@SG>4$`%/A$```F@@@G>4"/(WBO"_#X0D`H.&_'XWB!""@X_[__^L$`(GB
-M$!"=Y00@H./^___K"`")X@80H.$#/(WBM"#3X?[__^L$D*#A!W"(X`$PU^4"
-M,(/B`U"%X`4`6^'2___*%+"=Y0$\"./_/T_C`BR-XKX_PN%+,*#C`S/-Y5`P
-MF^4!,\WEC##;Y0`SS>5C,.#C`C/-Y0A@B>(X,YWE!@!3X0P``)HQ3HWB"""@
-MX[0A9.$$4*#C"0"@X000H.$%(*#A_O__ZP4`B>`%$(3@!2"@X?[__^L&D*#A
-M"0"@X<7?C>+PC[WH\$\MZ1S03>(4$(WE#""-Y1`PC>7@DI#EM'#2X0=P@^"D
-M,@/C`S#9YP``4^,$```*8#4#XP,PF><``%/C%4#@$S8``!K^___K#2"@X7\]
-MPN,_,,/C!""3Y0$@@N($((/EA(")XH1`F>5YOHGB#+"+XA!@G>7_H@#C"`"@
-MX000H.'^___K`0!0XQ8```H',&;@"@!3X09`X-,3``#:!%"@X2@PE.4``%/C
-M`$"4!?'__PH+`*#A9!"5Y?[__^L!`%#C!@``&@!PC>4)`*#A%!"=Y04@H.$&
-M,*#AU?S_ZP!@H.$`0)3EX___Z@!`H.,-(*#A?SW"XS\PP^,$()/E`2!"X@0@
-M@^7^___K$#"=Y09@8^`,()WEM&#"X0`PH..V,,+A!`"@X1S0C>+PC[WH<$`M
-MZ>!2D.4`0%/B#P``"K`PU.$``%/C`P``"@$`4^->0.`3#```&@0``.H%`*#A
-M_O__ZP``4.,$```*!0``Z@4`H.'^___K``!0XP$``!H`0.#C````Z@!`H.,$
-M`*#A<("]Z/!'+>D"8*#AX$*0Y00`H.'^___K``!0XP0``!KP`)_E\!"?Y?[_
-M_^L`0.#C-@``ZJ`U`^,#,)3G``!3XR\```JP,-;A`0!3XP0```K(`)_EP!"?
-MY?[__^L50.#C*@``Z@@[`>,#H)3GA'"$XH0PE.5X,(3E`F"&X@:`H.,'`*#A
-M>!"4Y?[__^L!`%#C!0``&@0`H.$&$*#A_O__ZP``4.,6```*%P``ZGA0E.4%
-M`*#A(#"0Y'@PA.4&$*#A"""@X?[__^L!`%#CZ___&@0`H.%X$)7E_O__ZP``
-M4.,'```*!`"@X0H0H.'^___K!`"@X080H.'^___K``!0XP$``!H`0.#C````
-MZ@!`H.,$`*#A\(>]Z/0!```4````$`(``#!`+>D4T$WB`%"@X0U`H.$-`*#A
-M`!"@XQ`@H./^___K`3"@X[`PS>$"`(WB`!"@XP8@H./^___KF#4#XP,`E><5
-M&PCC#2"@X0`PH./^___K%-"-XC"`O>@P0"WI%-!-X@!0H.$-0*#A#0"@X0`0
-MH.,0(*#C_O__ZP$PH..P,,WA`@"-XN`0A>(&(*#C_O__ZY@U`^,#`)7G%1L(
-MXPT@H.$`,*#C_O__ZQ30C>(P@+WH,$`MZ1303>(`4*#A#4"@X0T`H.$`$*#C
-M$""@X_[__^N8-0/C`P"5YQD;".,-(*#A`#"@X_[__^L4T(WB,("]Z/!/+>DL
-MT$WB`F"@X0-0H.'@0I#E!`"@X?[__^L``%#C@@``"F`U`^,#,)3G``!3XWX`
-M`!J@-0/C`S"4YP``4^-Z```*=34#XP,PU.<``%/C=@``"@PUU.4!`%/C`P``
-M&@0`H.'^___K`$"@XW```.IL,)3E(@T3XP,```H$`*#A_O__ZP!`H.-I``#J
-MM##6X4\/4^,?```:MC#6X0(`$^-B```*`6#5Y2``5N,@8*"C!'"-X@<`H.$`
-M$*#C)""@X_[__^L$`(?B%!"%X@8@H.'^___K!&"-Y?[__^L-,*#A?UW#XS]0
-MQ>,$,)7E`3"#X@0PA>4$`*#A!Q"@X?[__^L`0*#A!#"5Y0$P0^($,(7E_O__
-MZT(``.H+`%/C/0``F@4`H.$4$9_E#""@X_[__^L!`%#C-P``&K1PUN$,<$?B
-M#&"%X@0`C>(`$*#C)""@X_[__^OH@)_E`Z"-X@*0C>((L(WB&0``Z@8`H.$(
-M$*#A"B"@X?[__^L#4-WE4P!5XQ0``!H!8(;B`7!'XL=?Q^$&`*#A"!"@X0D@
-MH.'^___K`6"&X@%01>("(-WE`@!5X0,``+H$((WE"P"@X080H.'^___K`G#=
-MY0=@AN`%<&?@``!7X^/__\K^___K#3"@X7]=P^,_4,7C!#"5Y0$P@^($,(7E
-M!`"@X000C>+^___K`$"@X00PE>4!,$/B!#"%Y?[__^L"``#J!`"@X?[__^L`
-M0*#A``!4XP!`H!,````:`$#@XP0`H.$LT(WB\(^]Z"0````X`@``\$\MZ5G?
-M3>(`L*#A$!"-Y0*`H.$4,(WEX)*0Y;1@TN$&H*#A!@"@X?[__^L`4%#B"T#@
-M`W0!``H`$)CE#0"@X7\]P.,_,,/C"'"3Y09`D>`'0-0P`'"@,P``5^,%```:
-M!0"@X08@H.'^___K``!0XPH```H$``#J``!6XP<```H%`*#A!A"@X?[__^L%
-M`*#A"A"@X?[__^L-0.#C6@$`ZK8@V.%F-PCC`P!2X0`PH!,!,*`#"`!6XP`P
-MH-,``%/C%@``"@`P`.,`,$#C-#"3Y3PPC>4`,-7EW0!3XT8!`!H"`(7B/!"-
-MX@0@H./^___K`0!0XT`!`!H"#%;C`FR@HQ4-B>('`(#B!1"@X08@H.'^___K
-M2&>)Y0!`H.,W`0#J"P!6XP,``,H``%;C`$"@PPT``,H5``#J!0"@X=04G^4,
-M(*#C_O__ZP$`4./U__\:"P"@X1`0G>4((*#A!3"@X13__^L`0*#A)`$`Z@0P
-MU>=A($/B<B#OYAD`4N,@,$.2!##%EP%`A.($`%;A]O__R@!`H..`9)_E!'&6
-MYP<`H.'^___K`""@X04`H.$'$*#A_O__ZP``4.,#```*`4"$X@D`5./S__\:
-M[0``Z@@`5.,$\9^7Z@``ZB!)``#H20``=$H``+1*````2P``0$L``&!+``"`
-M2P``1$P``````.,``$#C_O__ZP`P`.,`,$#C%$"3Y0$`5.,$```:`T"@X1@`
-M@^+^___K`C"@XQ0PA.4`,`#C`#!`XP!`D^4``%3C"0``&M1SG^5]GZ#CT&.?
-MY0<`H.'^___K"0"@X?[__^L`0);E``!4X_C__PI<,(WB`"``XP`@0.,#`)+H
-M`R"@X00`@N2P$,+A\"X/X_\O3^,%$*#C%@Z-XK(0@.$+`*#A`AP(XTP@C>+^
-M___K!0"@X0`0`.,`$$#C`R"@X_[__^NT``#J````XP``0./^___K7#"-X@`@
-M`.,`($#C`P"2Z`,@H.$$`(+D`!#"Y?`N#^/_+T_C!!"@XQ8.C>*R$(#A"P"@
-MX0(<".-,((WB_O__ZP4`H.$`$`#C`!!`XP,@H./^___K`#``XP`P0.,40)/E
-M`@!4XY<``!H#0*#A&`"#XO[__^L!,*#C%#"$Y9$``.IL,)GE`0`3XP8```H%
-M`*#A`!``XP`00.-R-0'CTR"9X?[__^N'``#J!0"@X0`0`.,`$$#C`R"@X_[_
-M_^N!``#J"P"@X1`0G>4L((WB%#"=Y<3X_^L``%#C`$"@$RP@G06#/@T#&S-$
-M`Y,2PP#"+Z`!0TEB``4`H.$`$`#C`!!`XP0@H.'^___K;@``ZD`1F^4`(-'E
-M`3#1Y0(`T>4``(WE`P#1Y00`C>4$`-'E"`"-Y040T>4,$(WE!0"@X0`0`.,`
-M$$#C_O__ZUX``.H!,*#C1C7)Y04`H.$`$`#C`!!`XP,@H./^___K5@``Z@`P
-MH.-&-<GE!0"@X0`0`.,`$$#C`R"@X_[__^M.``#J/$"-X@4`H.$`$`#C`!!`
-MXP0@H.'^___K!`"@X0`0`.,`$$#C_O__ZP``4.,`,*`#2#"-!0X```H\`(WB
-M`!``XP`00./^___K``!0XP(PH`-(,(T%!@``"CP`C>(`$`#C`!!`X_[__^L`
-M`%#C!3"@`T@PC04`,`#C`#!`XTA`G>4`0,/E'$"-X@0`H.%($(WB!""@X_[_
-M_^L+`*#A$!"=Y00@H.$4,)WEZ_+_ZP4`H.$`$`#C`!!`XP,@H./^___K'0``
-MZ@`P`.,`,$#C`##3Y0``4^,%```*`@!3XPU`H`,#```*!0!3XPY`H`,````*
-M"T"@XP4`H.$`$`#C`!!`XP0@H.'^___K`#``XP`P0.,```#C``!`XP00H.$`
-M(-/E_O__ZP0``.H%`*#A`!``XP`00.,#(*#C_O__ZP"0F.6T0-CA!0"@X?[_
-M_^L!<(#B=W#_Y@<`5.$$<*`Q#2"@X7\]PN,_,,/C"&"3Y0=`F>`&0-0P`&"@
-M,P``5N,$```:"0"@X040H.$'(*#A_O__ZP!PH.$``%?C#4#@$P```!H`0*#C
-M!0"@X0H0H.'^___K!`"@X5G?C>+PC[WH)````#````!@`@```````'!`+>D"
-M4*#AX$*0Y00`H.'^___K``!0XP!`H`,?```*=34#XP,PU.<``%/C&@``"@`P
-ME>4#`%/C`_&?EP,``.JL30``I$T``+Q-``"T30``%4#@XQ$``.H`4*#C!```
-MZ@)0H.,"``#J!%"@XP```.H!4*#C!`"@X040H.'^___K``!0XP0```H$`*#A
-M!1"@X?[__^L`0*#C````Z@!`X.,$`*#A<("]Z/!'+>D`D*#A`:"@X0)PH.$#
-M@*#A'`"@X_[__^L`4*#A`$"@X0``4.,`0*`#*0``"A0`H./^___K`&!0X@0`
-M`!H%`*#A'!"@X_[__^L`0*#C(```Z@8`H.$`$*#C%""@X_[__^L!@,;E`'#&
-MY0$PH.,#,,;E`7!'XG=P[^8$`%?C$%"@@P`P`),`,$"3!W"#D#A0UY4$`(;B
-M"A"@X04@H.'^___K%#"@X[`PQ.$$8(3E"#"$Y0`PH.,,,(3E$#"$Y10`A.+^
-M___K2PV)X@00H.'^___K`$"@X00`H.'PA[WH$$`MZ04@0N)R(._F"`!2XP!`
-MH(,`P`"3`,!`DP(@C)!`0-*5!""@X;S__^L0@+WH\$\MZ1303>(`8*#A`5"@
-MX?P[".,#`%+AFP``"OX[".,#`%+A7D#@$Z8#`!JT`='A/P!0XY$``)H0,)'E
-M``!3XXX```K^___K`("@X0"@H.$``%#C"V#@`XD```H0$)7EM)'5X0T@H.%_
-M/<+C/S##XPAPD^4)0)'@!T#4,`!PH#,``%?C!```&@D@H.'^___K``!0XPD`
-M``H#``#J``!9XP8```H)$*#A_O__ZP@`H.&T$=7A_O__ZPU@X.-P``#J`#":
-MY0$P0^(#`%/C`_&?EP,``.KP3P``J%```,!0``#84```7F#@XTT``.H0$)KE
-MX$*6Y0PPVN4'`%/C"```BMPPVN$!(*#C$C.@X=P`$^,A```:(``3XQL``!H"
-M`!/C`0``&EY@X.,]``#J`B"@XZ`W`>,#((3G_Q`!X@$`4>,"```*`@!1X1,`
-M`!H&``#J!#"@XP@K`>,",(3G#"L!XP(PA.<`8*#C+0``Z@<@H.,(.P'C`R"$
-MYP8@H.,,.P'C`R"$YP!@H.,E``#J!@"@X>GK_^L`8*#A(0``Z@!@H.,?``#J
-MX`*6Y3`0BN*\(-KA4_;_ZP!@H.$9``#J!@"@X0H0H.&T(=7AT/3_ZP!@H.$3
-M``#JX$*6Y0PPFN4!`%/C`P``"@(`4^->8.`3#```&@0``.H$`*#A_O__ZP``
-M4.,$```:!0``Z@0`H.'^___K``!0XP$```H`8*#C````Z@!@X.,``%;C$```
-M&A``E>6TD=7A#2"@X7\]PN,_,,/C"'"3Y0E`D.`'0-0P`'"@,P``5^,#```:
-M"A"@X0D@H.'^___K`)"@X0``6>,-8.`3"`"@X;01U>'^___K````ZA5@X.,&
-M0*#A#@,`ZN`BMN5U-0/C`S#2YP``4^,`0.`#"`,`"A`PD>4``%/C%4#@`P0#
-M``JT`='A_O__ZP"PH.$`<*#A``!0XPM`X`/]`@`*$!"5Y;2!U>$-(*#A?SW"
-MXS\PP^,(H)/E"$"1X`I`U#``H*`S``!:XP0``!H((*#A_O__ZP``4.,)```*
-M`P``Z@``6.,&```*"!"@X?[__^L+`*#AM!'5X?[__^L-0.#CY`(`Z@`PE^4!
-M,$/B$@!3XP/QGY<2``#JH%(``+Q2``"84P``F%(``&!;``!D5```F%(``)A2
-M``"84@``F%(``)A2``"84@``F%(``)A2``"84@``_%,``/!;``"07```!%T`
-M`%Y`X..T`@#J`$"6Y00`H.'^___K!`"@X?[__^L`0*#AK0(`Z@!@EN5L,);E
-M$0`3XS````H$,)?E`0!SXP,``!JX(-?A`3B#X@,`4N$I```*5PV&XA``@.($
-M$(?B_O__ZP!`4.(+0.`#FP(`"A"`E^6\,-?AU#"$Y1,.A.(4$(?B$""@X_[_
-M_^L"#!CC`3"@$]PPA!4`,*`#W#"$!<`TEN4``%/CW#"$!0(+&.,`,*`#&#:$
-M!0<```H!,*#C&#:$Y=PPA.5C#H3B`P"`X"00A^(:(*#C_O__Z\PTEN4``%/C
-M&#:$!08`H.$$$*#A_O__ZP!`H.-X`@#J%4#@XW8"`.H`8);E;#"6Y1$`$^,2
-M```*!#"7Y0$`<^,#```:N"#7X0$X@^(#`%+A"P``"E<-AN(0`(#B!!"'XO[_
-M_^L`0%#B`$"@`V0"``H&`*#A!!"@X?[__^L`0*#C7P(`ZA5`X.-=`@#JM('5
-MX0!@EN5L,);E$``3XQ(```J81P'C!`"&X`P0A^("(*#C_O__Z[0PEN$!,$/B
-M<S#_YA\`4^,$,*"!(""@@[,@AH$&`*#A#A"'X@X@2.+^___K`0!0XP!`H`-%
-M`@`*%4#@XT,"`.JT(=7A`&"6Y0`PH.,@,(?E&S#'Y;XRU^%`,(/B`P!2X5T"
-M`!H$,)?E`0!SXP<``!JX(-?A`3B#X@,`4N$#```:)##7Y0,`4^-3`@"*!@``
-MZE<-AN(0`(#B!!"'XO[__^L`@%#B0@(`&DD"`.H,0(?B!`"@X2@9G^7^___K
-M``!0XT,"``H$`*#A&!F?Y?[__^L!`'#B``"@,P``4.,`@*`#`3"@`U4```HD
-M@-?EOJ+7X0$P>N(`,*`S`P!8XP$P@X,``%/C-`(`&@``6N,`0*`##0``"@4`
-M6N,%H*"3#:"@@PR0BN()`*#A_O__ZP!`4.(G`@`*!`"@X0`0H.,<(*#C_O__
-MZPB@A.4`D(3E!("$Y0R0A.()`*#A,!"'X@@@E.7^___K'##7Y0``4^,A```*
-M`""@XPP[`>,#((;G`3"@XZ0G`>,",(;G6"""X@(PAN<(,)3E#0!3XP4PH`-8
-M($("`C"&!U@@@@(",(8'J#<!XP.`AN<(,H/@`P"&X`0`@.()$*#A"""4Y?[_
-M_^M?/HCB"C"#X@,QAN`(()3E!""#Y08`H.$,$(3B""#4Y0@PH.$N_O_K20$`
-MZJ@'`>,(`H#@``"&X`0`@.()$*#A"""4Y?[__^M?/HCB"C"#X@,QAN`(()3E
-M!""#Y08`H.$,$(3B""#4Y0@PH.$<_O_K-P$`Z@``4^-K```*;#"6Y1``$^-H
-M```*'##7Y0$`4^/<`0`:``!0XQ$```HD`-?E!@V`X@`"AN"^(M?A!`"`XC`0
-MA^(0`%+C$""@(_[__^L!(*#C_#<!XP,@AN>^,M?A#0!3XP0@@@+\-P$#`R"&
-M!S@``.H$`*#A,!>?Y?[__^L``%#C'@``&@(@H./\-P'C`R"&YR0`U^4&#8#B
-M``*&X#!`A^*^(M?A!`"`X@00H.$0`%+C$""@(_[__^LD`-?E80^`X@`"AN`$
-M`(#B$!"$X@@@H./^___K)`#7Y6(/@.(``H;@!`"`XA@0A.(((*#C_O__ZP$@
-MH./Y.@'C`R#&YQ0``.H$`*#AI!:?Y?[__^L``%#C#```&@0@H./\-P'C`R"&
-MYR0`U^4&#8#B``*&X+XBU^$$`(#B,!"'XA``4N,0(*`C_O__ZP(``.H`(*#C
-M_#<!XP,@AN<D(-?E!CN@XP,@AN<!(*#COC^#X@,@QN>_/T/B`R"6YU@P0^(#
-M((;G!@"@X3`0A^)R(._F)##7Y7_]_^L&`*#A_O__ZP"`4.)\`0`*`$"@X^A`
-MB.7\-P'C`S"6Y^PPB.55`0#JH#<!XP,PEN<"`%/C`#"@$P$PH`,``%CC`#"@
-M`P``4^-M`0`*;#"6Y1``$^-J`0`*'##7Y0$`4^-4```:,*"'XKXBU^$1#HCB
-M"A"@X1``4N,0(*`C_O__ZP0`H.&,%9_E_O__ZP``4.,&```:`3"@X^PPB.6^
-M,M?A#0!3XP4PH`/L,(@%&@``Z@0`H.%@%9_E_O__ZP``4.,-```:`C"@X^PP
-MB.7P`(CB$!"*X@@@H./^___K`0R(XA@0BN(((*#C_O__ZP$@H./Y.@'C`R#&
-MYP<``.H$`*#A&!6?Y?[__^L``%#C!#"@`^PPB`4`,*`3[#"(%1P`H./^___K
-M`)"@X0``4.,>```*%P"@X_[__^L`H%#B`P``&@D`H.$<$*#C_O__ZQ8``.H4
-M`(GB_O__ZQ4PH..P,,GA!*")Y1<PH.,(,(GE`#"@XPPPB>40,(GE[#"8Y08P
-MRN4*`*#AX!"(X@8@H./^___K!P"*XA$>B.(0(*#C_O__ZTL-AN()$*#A_O__
-MZP!`H./H0(CE\0``Z@``4.,1```*)`#7Y08-@.(``H;@OB+7X00`@.(P$(?B
-M$`!2XQ`@H"/^___K`2"@X_PW`>,#((;GOC+7X0T`4^,$((("_#<!`P,@A@<X
-M``#J!`"@X0@4G^7^___K``!0XQX``!H"(*#C_#<!XP,@AN<D`-?E!@V`X@`"
-MAN`P0(?BOB+7X00`@.($$*#A$`!2XQ`@H"/^___K)`#7Y6$/@.(``H;@!`"`
-MXA`0A.(((*#C_O__ZR0`U^5B#X#B``*&X`0`@.(8$(3B"""@X_[__^L!(*#C
-M^3H!XP,@QN<4``#J!`"@X7P3G^7^___K``!0XPP``!H$(*#C_#<!XP,@AN<D
-M`-?E!@V`X@`"AN"^(M?A!`"`XC`0A^(0`%+C$""@(_[__^L"``#J`""@X_PW
-M`>,#((;G)"#7Y08[H.,#((;G`2"@X[X_@^(#(,;GOS]#X@,@EN=8,$/B`R"&
-MYP8`H.$P$(?B<B#OYB0PU^6U_/_K!@"@X?[__^L`@%#BL@``"@!`H./H0(CE
-M_#<!XP,PEN?L,(CEBP``Z@``5..)```*!`"@X0P0BN+^___K`$"@XX0``.H`
-M0);E;#"4Y1$`$^,=```*!#"7Y0$`<^,#```:N"#7X0$X@^(#`%+A%@``"E<-
-MA.(0`(#B!!"'XO[__^L`0%#B`$#@`W(```H(-]3EW0!3XS``4Q,`0*`3;0``
-M&@DGU.4"((+B(`!2XR`@H",,((?E$`"'X@<<A.(($('B_O__ZP!`H.-B``#J
-M%4#@XV```.JT,=7A'"*?Y4P@DN4,((WE`$"6Y6P@E.40`!+C'0``"@Y@0^)L
-M!Y3E``!0XP,```IX%Y3E_O__ZP`PH.-L-X3E``!6XP!`H---``#:!@"@X?[_
-M_^ML!X3E>&>$Y0``4.,,```*#A"'X@8@H.'^___K!`"@X=T0H.,,((WB`3"@
-MX_[__^L!(*#CN#(!XP,@Q.<`0*#C.@``ZA5`X.,X``#JM#'5X0!`EN5L()3E
-M$``2XQ4```H.8$/B<`>4Y0``4.,#```*?!>4Y?[__^L`,*#C<#>$Y0``5N,`
-M0*#3*```V@8`H.'^___K<`>$Y7QGA.4``%#C!```"@X0A^(&(*#A_O__ZP!`
-MH.,=``#J%4#@XQL``.JT,=7A`$"6Y6P@E.40`!+C%0``"@Y@0^)T!Y3E``!0
-MXP,```J`%Y3E_O__ZP`PH.-T-X3E``!6XP!`H-,+``#:!@"@X?[__^MT!X3E
-M@&>$Y0``4.,$```*#A"'X@8@H.'^___K`$"@XP```.H50.#C``!4XQ```!H0
-M`)7EM&'5X0T@H.%_/<+C/S##XPB`D^4&,)#@"##3,`"`H#,``%CC`P``&@<0
-MH.$&(*#A_O__ZP!@H.$``%;C#4#@$PL`H.&T$=7A_O__ZP0`H.$4T(WB\(^]
-MZ`Q`A^($`*#A)!"?Y?[__^L!`'#B``"@,P`PH.,:_O_J`$"@X]S__^H50.#C
-MVO__ZA0!```0`0``'`$``"0!````````$$`MZ0!``.,`0$#C`#"@XQ0PA.5D
-M`*#C_O__ZQ1`E.4"`%3C`0``&@P`G^7^___K!`"?Y?[__^L0@+WH&````'!`
-M+>D`0`#C`$!`XQA0A.(%`*#A`!"@XP`@`.,`($#C_O__ZP4`H.'^___K`C"@
-MXQ0PA.5P@+WH0$(/`("$'@!@[%,`P-BG`("-6P!`5(D``!NW`("H$@$`-FX!
-M`%$E`@!LW`*`^3<#B`(``+@"``!X`P``@`,``(P#``"4`P``H`,``+`#``"X
-M`P``.``<`!4```!L````3`$``%``````````````````````````````````
+MH.,'((WB,#4#XP_@H.$#\)#G!S#=Y0,`4^,``%,3`:"@`P*@H!,`8*#C!I"@
+MX61U`^,`@.#C"P``Z@4`H.$&$*#A!""@X0@PH.$/X*#A!_"5YP%`A.(!#%3C
+M]O__&@%@AN(*`%;A`0``J@E`H.'Q___J"-"-XO"'O>@``*#C'O\OX01`+>6`
+M0Y#E;#"4Y0$`$^,'```:`#"@XRHF`^,",,3G*R8#XP(PQ.<L)@/C`C#$YPL`
+M`.J,-0'C`Q#4YXXU`>,#(-3GBC4!X],`E.$K-@/C`P#$YRHV`^,#$,3G+#8#
+MXP,@Q.</(*#C+38#XP,@Q.<V#(3B*`"`XA``O>@>_R_A<$`MZ0-`H.&`4Y#E
+M!0"@X08`D^C_/P_C#S!`XV3%`^,/X*#A#/"5YP!0H.$$`*#A`!``XP`00.,%
+M(*#A_O__ZP``H.-P@+WH\$\MZ:G?3>("D*#A`V"@X8"SD.5J/0_C_S]/XP!`
+MH.,J+HWBLT""X6@]#^/_/T_CLT""X2(.C>($$*#A@""@X_[__^L@`(WB!!"@
+MX0(LH./^___K`!"9Y;1PV>$-P*#A?SW,XS\PP^,(4)/E!T"1X`5`U#``4*`S
+M``!5XP4``!H&`*#A!R"@X?[__^L``%#C<0$`&@8``.H``%?C!```"@8`H.$'
+M$*#A_O__ZPT`X.-L`0#J`$"@XPQ`C>400(WE%$"-Y1Q@C>4<<(WB`(``XP"`
+M0.,,H(WB!%"@X0,``.H,`%7C!@``"@5`BN<$4(7B!P"@X0@0H.'^___K`$!0
+MXO;__QH,0)WE!`"@X0`0`.,`$$#C_O__ZP``4.,\```:"P"@X0`0H..`(*#C
+M(CZ-XO[__^L!`%#C1P$`&@8`H.$`$*#C!""@X_[__^L&`*#A&!6?Y08@H.'^
+M___K`*"@XPRUG^4`@`#C`(!`XP8`H.$+$*#A!B"@X0HPH.'^___K(BZ-X@I0
+M@N`%<*#A`$"@XP8`H.$($*#A!B"@X0$PU^3^___K`4"$X@@`5./W__\:!@"@
+MX;P4G^4&(*#A_O__ZP8`H.$($*#A!B"@X0@PU>7^___K`4"$X@%0A>(0`%3C
+M]O__&@8`H.&,%)_E!B"@X?[__^L0H(KB@`!:X]K__QH&`*#A_O__Z[0`R>$`
+M`*#C%`$`Z@0`H.$`$`#C`!!`X_[__^L``%#C00``&A``G>4``%#C"@$`"A1`
+MG>4``%3C!P$`"AA0C>(%$*#A$""@X_[__^L`<*#A!`"@X040H.$*(*#C_O__
+MZW!0_^8``%7C^P``"G=P_^9J30_C_T]/XP`0H.,`$(WE"P"@X0,@H.,JSHWB
+M!#",X/[__^L%@*#A!S"%X"HNC>*T0)+A!`!3X>D``,H+`*#A!Q"@X04@H.$B
+M/HWB_O__ZP8`H.$`$*#C!""@X_[__^L`0*#CG%.?Y2)^C>*8HY_E"0``Z@8`
+MH.$%$*#A!B"@X00PU^?^___K!@"@X0H0H.$&(*#A_O__ZP%`A.((`%3A\___
+MN@8`H.'^___K`0"`XK0`R>$``*#CS```Z@0`H.$`$`#C`!!`X_[__^L``%#C
+M,```&B`PC>(`,(WE"P"@X0`0H.,!(*#A`CR@X_[__^L``%#CN@``"@8`H.$`
+M$*#C!""@X_[__^L`0*#C`%``XP!00.,@<(WB`*``XP"@0.,`@`#C`(!`XP8`
+MH.$%$*#A!B"@X00PU^?^___K#S`$X@\`4^,$```:!@"@X0@0H.$&(*#A_O__
+MZP8``.H',`3B!P!3XP,``!H&`*#A"A"@X08@H.'^___K`4"$X@(,5./H__\:
+M!@"@X?[__^NT`,GA``"@XY4``.H$`*#A`!``XP`00./^___K``!0XS```!H0
+M0)WE``!4XXL```H40)WE``!4XX@```IJ30_C_T]/XP`0H.,`$(WE"P"@X0,@
+MH.,JSHWB!#",X/[__^LJ+HWBM$"2X14`5.-Y``#:"P"@X180H.,&(*#C(CZ-
+MXO[__^L&`*#A`!"@XP0@H./^___K`%"@X]QQG^4B3HWBV(&?Y08`H.$'$*#A
+M!B"@X04PU.?^___K!@"@X0@0H.$&(*#A_O__ZP%0A>(&`%7C\___&@8`H.'^
+M___KM`#)X0``H.->``#J!`"@X0`0`.,`$$#C_O__ZP``4.,P```:$$"=Y0``
+M5.-4```*%$"=Y0``5.-1```*:DT/X_]/3^,`$*#C`!"-Y0L`H.$#(*#C*LZ-
+MX@0PC.#^___K*BZ-XK1`DN$)`%3C0@``V@L`H.$*$*#C!""@XR(^C>+^___K
+M!@"@X0`0H.,$(*#C_O__ZP!0H.,`<9_E(DZ-XOR`G^4&`*#A!Q"@X08@H.$%
+M,-3G_O__ZP8`H.$($*#A!B"@X?[__^L!4(7B!`!5X_/__QH&`*#A_O__Z[0`
+MR>$``*#C)P``Z@0`H.$`$`#C`!!`X_[__^L``%#C%```&FA-#^/_3T_C"P"@
+MX2H^C>($$(/@_O__ZPL`H.'^___K*LZ-XK1`G.$`,&3@!@"@X0`0`.,`$$#C
+M!B"@X?[__^L&`*#A_O__Z[0`R>$``*#C#```Z@8`H.$`$`#C`!!`XP8@H.'^
+M___K!@"@X?[__^NT`,GA``"@XP(``.H-`.#C````ZA4`X..IWXWB\(^]Z!0`
+M```<````,````#0```!`````3````/!!+>D(T$WB`X"@X8!SD.4"8*#A`#"@
+MXP0PC>4`$)+E#2"@X7\]PN,_,,/C"$"3Y010D>($4-4P`$"@,P``5.,#```:
+M!`"-X@0@H./^___K`@``Z@0`C>($$*#C_O__ZX@U`^,#,)?G`6!VX@!@H#,`
+M`%/C`6"&$P``5N,50.`3)@``&@1`G>4``%3C`##8!00PC04$,)WE`0!3XP@`
+M`!K$-`/C`S"7YP``4^,:```*!P"@X0D0H.,S_R_A`$"@XQ8``.H"`%/C"```
+M&L0T`^,#,)?G``!3XP\```H'`*#A"A"@XS/_+^$`0*#C"P``Z@,`4^,(```:
+MQ#0#XP,PE^<``%/C!```"@<`H.$,$*#C,_\OX0!`H.,```#J`$"@XP0`H.$(
+MT(WB\(&]Z/!%+>FIWTWB@*.0Y0!`H.,,0(WE$$"-Y11`C>5J+0_C_R]/XRH>
+MC>*R0('A'#"-Y1Q@C>(`<`#C`'!`XPR`C>(#``#J#`!4XP8```H$4(CG!$"$
+MX@8`H.$'$*#A_O__ZP!04.+V__\:#$"=Y00`H.$`$`#C`!!`X_[__^L``%#C
+M+P``&A``G>4``%#CO0``"A10G>4``%7CN@``"A@0C>(0(*#C_O__ZP"`H.$%
+M`*#A_O__ZZ!PL.$`8*`3(DZ-$K0```H$``#J`@!5Y0$05>7^___K!@#$YP%@
+MAN("4(7B!P!6X??__SIX4._F:DT/X_]/3^,`$*#C`!"-Y0H`H.$#(*#C*LZ-
+MX@0PC.#^___K!S"%X"H>C>*T0)'A!`!3X9P``(H*`*#A!1"@X7<@_^8B/HWB
+M_O__ZP``4..5```*D@``Z@0`H.$`$`#C`!!`X_[__^L``%#C(@``&A``G>4`
+M`%#CAP``"A10G>4``%7CA```"A@0C>(0(*#C_O__ZP"`H.$%`*#A_O__ZZ!P
+ML.$`8*`3($"-$GX```H$``#J`@!5Y0$05>7^___K!@#$YP%@AN("4(7B!P!6
+MX??__SH@,(WB`#"-Y0H`H.$!$*#C>"#OYG<P_^;^___K``!0XVP```II``#J
+M!`"@X0`0`.,`$$#C_O__ZP``4.,L```:$%"=Y0``5>->```*%$"=Y0``5.-;
+M```*!0"@X?[__^N@<+#A6P``"@8`5^,`8*"3(DZ-DE<``(H$``#J`@!5Y0$0
+M5>7^___K!@#$YP%@AN("4(7B!P!6X??__SIJ30_C_T]/XP`0H.,`$(WE"@"@
+MX0,@H.,JSHWB!#",X/[__^L6,(?B*AZ-XK1`D>$$`%/A0```B@H`H.$6$*#C
+M=R#_YB(^C>+^___K``!0XSD```HV``#J!`"@X0`0`.,`$$#C_O__ZP``4.,J
+M```:$$"=Y0``5.,K```*%%"=Y0``5>,H```*!`"@X?[__^N@<+#A*```"@10
+MH.$`8*#C(DZ-X@``U>4!$-7E_O__ZP8`Q.<!8(;B`E"%X@8`5^'W__^*:DT/
+MX_]/3^,`$*#C`!"-Y0H`H.$#(*#C*LZ-X@0PC.#^___K"C"'XBH>C>*T0)'A
+M!`!3X0\``(H*`*#A"A"@XW<@_^8B/HWB_O__ZP``4.,(```*!0``ZB0`G^7^
+M___K``"@XP0``.H5`.#C`@``Z@``H.,```#J#0#@XZG?C>+PA;WHQ````/!`
+M+>D4T$WB`D"@X8!CD.4`,`#C`#!`XP!0T^4``%7C"```&@-0H.$`,`#C`#!`
+MXP4`H.$`$)/E$""@X_[__^L`,*#C#S#%Y;0PU.$0`%/C6```B@`0E.4-(*#A
+M?SW"XS\PP^,(4)/E$$"1X@5`U#``4*`S``!5XP4``!H-`*#A$""@X_[__^L`
+M`%#C!0``"D@``.H-`*#A$!"@X_[__^L-0.#C1```Z@```.,``$#C#1"@X?[_
+M_^L``%#C`$"@`ST```H&`*#A#1"@X?[__^L`0%#B.```&@```.,``$#C`!``
+MXP`00.,)(*#C_O__ZP$`4.,(```:R%"?Y1!PU>73/:#C`W#&YP8`H.'^___K
+M$5#5Y6$R`^,#4,;G`%``XP!00.,-<*#A!0"@X0T0H.$0(*#C_O__ZP`PH.,/
+M,,7E#0"@X0`0`.,`$$#C"2"@X_[__^L!`%#C%P``&@8`H.$!$*#C_O__Z\0T
+M`^,#,);G``!3XP(```H&`*#A!Q"@XS/_+^$\4)_ETSV@XP,@UN<0(,7E`'"@
+MXP-PQN<&`*#A_O__ZV$R`^,#(-;G$2#%Y0-PQN<```#J#4#@XP0`H.$4T(WB
+M\("]Z``````00"WI<#(#XP,PD.?_-,/C_S##XP$(4^,F```*9#(#XP,PT.<`
+M`%/C)```"G$R`^,#,-#G`0!3XP,``!I,-@/C`S"0YP$`4^,:```*;#"0Y0$`
+M$^,9```:N#(#XP,PD.<"`%/C%0``"K`R`^,#,)#G``!3XQ$``!H`,`#C`#!`
+MXP`PD^6H(@/C`B"0YV00H..1`@'@TRT$XV(@0>.2P8'@R0V`XC0`@.(A$X/@
+M_O__ZP%`H.,"``#J`$"@XP```.H!0*#C!`"@X1"`O>CP02WI"-!-X@!@H.$"
+M4*#A`T"@X0,`H.$`$`#C`!!`XP0@H./^___K``!0XR<```JT(-7A!"!"XG(@
+M_^:T(,7A!#"$XH"#EN4!($+B`0!2XP,```H"`%+C`'"@$P@``!H#``#J`'#3
+MY3!P1^)W<._F`P``Z@``T^4!$-/E_O__ZP!PH.$*`%?C$```BF0R`^,#,-CG
+M!P!3X0P```H``%?C`B"@$V,R`Q,#(,@7`0``&@@`H.'^___K9#(#XP-PR.<`
+M<%?B`7"@$V(R`^,#<,CG!`"@X0`0`.,`$$#C!""@X_[__^L``%#C*0``"K0P
+MU>$$,$/BM##%X8!3EN4(((WB`#"@XP0P(N4$`(3B`!``XP`00./^___K!#"=
+MY0$`4^,3``"*82(#XP(PQ><!(*#C9#(#XP,@Q><`,`#C`#!`XP`PD^6H(@/C
+M`B"5YV00H..1`@'@TRT$XV(@0>.2`8'@R0V%XC0`@.(A$X/@_O__ZP<``.H"
+M`%/C!0``&@4`H.'^___K``!0XP`@H!-D,@,3`R#%%P``H.,(T(WB\(&]Z!!`
+M+>F``Y#E!@"3Z/[__^L``*#C$("]Z/!!+>D0T$WB@&.0Y0!`DN5T</_F5%CG
+MYP0PDN4,,(WE)$R@X7%`1.(.`%3C!/&?E\8``.H0%0``\!<``&05``#P%P``
+M@!4``*05``#P%P``\!<``/`7``#P%P``\!<``/`7``#P%P``\!<``.05```"
+M`%7C"```"@0`5>,+```*`0!5X[$``!H&`*#A!Q"@X7,@[^;^___KK```Z@8`
+MH.$'$*#A<R#_YO[__^NG``#J!@"@X0<0H.$#(*#A_O__ZZ(``.H&`*#A!Q"@
+MX0`@X.-@Q0/C#^"@X0SPEN>;``#J`#"-Y08`H.$%$*#A!R"@X0`PX.-HQ0/C
+M#^"@X0SPEN>2``#J``!5XP`@H`.(-0$#`R#&!XT```H!`%7CBP``&@$@H..(
+M-0'C`R#&YPQ`G>5D`%3C9$"@(XDU`>,#0,;G@@``Z@P`5>-(```*!@``B@8`
+M5>,4```*"0!5XR(```H%`%7C>0``&@H``.K=`%7C2```"@(``(H1`%7C<P``
+M&D$``.KN`%7C40``"OT`5>-N```:9```ZE<-AN(H`(#BX!"&XO[__^MH``#J
+M"T"-X@8`H.$4$*#C!""@X3`U`^,/X*#A`_"6YP]P!^(+<,WE!@"@X100H.,$
+M(*#A+#4#XP_@H.$#\);G6```ZO[__^L-(*#A?SW"XS\PP^,$()/E`2""X@0@
+M@^57C8;B.("(X@!PH..O7X?B`U"%XH51AN``0)CE````Z@!`E.4%`*#A!!"@
+MX?[__^L``%#C^?__"@%PA^((@(CB(`!7X_#__QH-(*#A?SW"XS\PP^,$()/E
+M`2!"X@0@@^7^___K-P``Z@8`H.$&$*#C#""-XC@U`^,/X*#A`_"6YS```.I3
+M)@/C`C#&YRT``.H``%/C`@``&@8`H.'^___K*```Z@$`4^,"```:!@"@X?[_
+M_^LC``#J`@!3XR$``!H&`*#A_O__ZQX``.H/`%/C!@``&@8`H.$'$*#C"R"-
+MXC0U`^,/X*#A`_"6YQ4``.H&`*#A!Q"@XPP@C>(X-0/C#^"@X0/PEN<&`*#A
+M!Q"@XPL@C>(T-0/C#^"@X0/PEN<(``#J=W#OY@8`H.'%'J#C!R"@X?[__^L&
+M`*#A6!P`XP<@H.'^___K``"@XQ#0C>+P@;WH$$`MZ8!#D.4`$-+E417$Y00`
+MH.'^___K`0!0XP``X!,``*`#$("]Z/!/+>D\T$WB@%.0Y8@U`^,#,)7G`I"@
+MX0$@<N(`(*`S``!3XP(PH`$!,((3``!3XP!`H`,>8*`#!0``"HL``.H&`*#A
+M_O__ZP%`A.)E`%3C`@``"FPPE>4B#1/C]___&@`@H..V(,GAM##9X1\`4^-^
+M``":`!"9Y0T@H.%_/<+C/S##XPA@D^4@0)'B!D#4,`!@H#,``%;C!0``&@P`
+MC>(@(*#C_O__ZP``4.,%```*;@``Z@P`C>(@$*#C_O__ZQ5`X.-L``#J_O__
+MZPT@H.%_/<+C/S##XP0@D^4!((+B!""#Y81`A>*$H)7E`+"@XRR`C>(``XWH
+M!)"@X0D`H.$*$*#A_O__ZP$`4.,\```*"T"@X0Q0C>(``-7EKOG_ZP!P4.(0
+M``"Z`0#UY:KY_^L`8%#B#```N@%0A>('8H;A!&#(YP0`5.,#``#*`##5Y3H`
+M4^,$```:`5"%X@%`A.(&`%3CZ___&D8``.H-(*#A?SW"XS\PP^,$()/E`2!"
+MX@0@@^7^___K%4#@XSH``.J@8(7BD""5Y08`H.$T$(WB#"!"XO[__^L``%#C
+M!0``"C1`G>4``%3C!)"=%0$PH!.V,,D1#P``&I`@E>4&`*#A-!"-X@P@0N+^
+M___K``!0XP4```HT0)WE``!4XP20G14"(*`3MB#)$0(``!H`H)KEO?__Z@20
+MG>4-(*#A?SW"XS\PP^,$()/E`2!"X@0@@^7^___KM##9X2$`4^,1``":``"9
+MY2``@.(-(*#A?SW"XS\PP^,(4)/E`4"0X@5`U#``4*`S``!5XP0``!H&$(GB
+M`2"@X_[__^L``%#C`0``"A5`X.,```#J`$"@XP0`H.$\T(WB\(^]Z`I0H.$`
+M`)WE(!"*X@8@H./^___K`0!0X]7__QJY___J\$<MZ0C03>("0*#A@&.0Y;10
+MTN$``%7CC0``"@`PDN4``%/CB@``"K:0TN$%<*#A!0"@X?[__^L`@%#B"T#@
+M`X0```H`$)3E#2"@X7\]PN,_,,/C"*"3Y0=0D>`*4-4P`*"@,P``6N,%```:
+M"`"@X0<@H.'^___K``!0XW@``!H&``#J``!7XP0```H(`*#A!Q"@X?[__^L-
+M0.#C<P``Z@A0H.$`,)CE(@!3XQ5`X(-N``"*"%"(X@8`4^,V```*!```B@(`
+M4^,'```*`P!3XTH``!H:``#J!P!3XS<```H?`%/C10``&CX``.H$,)7E`@!3
+MXP@```H$`%/C"P``"@$`4^,]```:!@"@X0`0E>7^___K"`"%Y3@``.H&`*#A
+M`!"5Y?[__^L(`(7E,P``Z@8`H.$`$)7E_O__ZP@`A>4N``#J!#"5Y0(`4^,(
+M```*!`!3XPL```H!`%/C)P``&@8`H.$`$)7E""#5Y?[__^LB``#J!@"@X0`0
+ME>6X(-7A_O__ZQT``.H&`*#A`!"5Y0@@E>7^___K&```Z@8`H.$`$-7E!"#5
+MY0`PX.-DQ0/C#^"@X0SPEN<(`(7E#P``Z@`0U>4$(-7E"#"5Y0`PC>4&`*#A
+M`##@XVC%`^,/X*#A#/"6YP4``.H&`*#A*!"@XP`@H.,L-0/C#^"@X0/PEN=Y
+MD._F``!9XQ<``!H``)3E#2"@X7\]PN,_,,/C"%"3Y0=`D.`%0-0P`%"@,P``
+M5>,'0*`1`P``&@@0H.$'(*#A_O__ZP!`H.$``%3C!@``"@,``.H50.#C!`"@
+MX0C0C>+PA[WH#4#@XP```.H`0*#C"`"@X0<0H.'^___K]?__ZG!`+>D#0*#A
+M@`.0Y0`0D^7^___K`%"@X00`H.$`$`#C`!!`XP4@H.'^___K``"@XW"`O>CP
+M1RWI$-!-XH!3D.4#8*#A`#"@XP@PC>6\,,WA`#"-Y;0PS>$-`*#A!A"&X@8@
+MH./^___K`#"6Y0$`4^,K```:#0"@X0@0C>(&(*#C_O__ZP$`4.-1```*`$"@
+MXPUPH.$&@*#C=)#OY@2@H.$$`X7@)@R`XB$`@.(-$*#A"""@X?[__^L!`%#C
+M#P``&@2CH.$*`(7@)@R`XB<`@.(4$(;B$""@X_[__^L*H(7@)JR*XB"@BN(!
+M0*#C`$#*Y020B>`@.@+C`Y#%YS<``.H!0(3B$`!4X^+__QHV``#J`""@XR`Z
+M`N,#(,7G`4"@XRX``.H"`%/C'0``&@!`H.,-8*#A!G"@XP2`H.$$`X7@)@R`
+MXB$`@.(-$*#A!R"@X?[__^L!`%#C#0``&@2#H.$(`(7@)@R`XB$`@.(`$*#C
+M!B"@X_[__^L(4(7@)ER%XB!0A>(`,*#C`##%Y0%`H.,2``#J`4"$XA``5./E
+M__\:#0``Z@,`4^,)```:)@R%XB``@.(`$*#C`2N@X_[__^L`(*#C(#H"XP,@
+MQ><!0*#C`@``Z@!`H.,```#J`4"@XP0`H.$0T(WB\(>]Z"!*`N,$`-7G``.%
+MX"8,@.(A`(#B#1"@X08@H./^___K!`#5YP`#A>`F#(#B)P"`XA00AN(0(*#C
+M_O__ZP0PU><#,X7@)CR#XB`P@^(!(*#C`"##Y00PU><",(/@<S#OY@0PQ><0
+M`%/CX/__&JS__^IP0"WI`D"@X8!CD.5L();E`0`2XP<``!I``!+C!0``&@``
+MH..T`,3AMC#4X0(Y@^.V,,3A<("]Z`90U.4``%7C!```"@0`5>,5`."#`5!%
+MD@(``)IP@+WH7RV@XP)0EN<!$(7B<1#_YK80Q.$D*P'C`B"6YP8`4N,"\9^7
+M,P``ZE@@``!$(```^"```$0@``#@(```^"```.`@`````*#CM`#$X0(9@>.V
+M$,3A<("]Z`8LA>("(8;@M"#2X;0@Q.$``%+C%@``"E\?A>(!$H;@!ER%X@51
+MAN`#`*#A!!"!X@0@E>7^___KMB#4X;8@Q.$@.P'C`S"6YP``4^,"*H(#MB#$
+M`0``H`-P@+T(`0!3XP``H!,!*8(#MB#$`0``H`-P@+WH``"@X[0`Q.$"&8'C
+MMA#$X7"`O>@0,*#CM##$X0H;@>.V$,3A``"@XW"`O>@``*#CM`#$X0(9@>.V
+M$,3A<("]Z!!`+>D``%/B!P``"@[`H..TP,+A`3"@X[8PPN$`$`#C`!!`XPP@
+MH.'^___K``"@XQ"`O>AP0"WI`E"@X8!#D.5L()3E`0`2XP(``!I``!+C`$#@
+M`P@```KH8)3EM&#%X0,`H.'L$(3B!B"@X?[__^L!,*#CMC#%X0!`H.,$`*#A
+M<("]Z'!`+>F`4Y#E`D"@X0$PH..R,,3@!`"@X0`0H.,&(*#C_O__ZVPPE>4!
+M`!/C`P``&D``$^,!```:$``3XP0```H$`*#AX!"%X@8@H./^___K`P``Z@0`
+MH.$`$*#C!B"@X_[__^L``*#C<("]Z/!!+>D@T$WB`F"@X0-PH.&`0Y#E!`"-
+MX@`0H.,<(*#C_O__Z[8PUN$""1/C#0``"@$@H.,D.P'C`R"$YP`PH..\)P'C
+M`C"$YQ0H`>,",(3GN"<!XP(PA.<@*P'C`C"$YP-`H.%M``#J_U`3X@4```H$
+M`%7C%0#@@P%019(!@*"3`P``FF8``.I?+:#C`E"4YP"`H.,""A/C"P``"@`P
+MH.,D*P'C`C"$Y[@G`>,",(3GO"<!XP(PA.<4*`'C`C"$YR`K`>,",(3G&0``
+MZ@$)$^,,```*`""@XR0[`>,#((3G`3"@X[@G`>,",(3GO"<!XP(PA.<4*`'C
+M`C"$YR`K`>,",(3G"@``Z@`PH.,D*P'C`C"$Y[@G`>,",(3GO"<!XP(PA.<4
+M*`'C`C"$YR`K`>,",(3G"%"-Y;0PUN$``%/C!@``"@4`4^,%,*"3#3"@@PPP
+MC>4,,(/B!#"-Y1P``.H`,*#C##"-Y0$`6.,8```:7SV@XP-0A.<&7(7B!5&$
+MX`0PE>4%`%/C`@``"@T`4^,*```:!```Z@$@H..\-P'C`R"$YP!`H.,<``#J
+M!2"@X[PW`>,#((3G`$"@XQ<``.H`,*#CO"<!XP(PA.<#0*#A$@``Z@@PG>4"
+M,8/C"#"-Y010C>(,`(7B!Q"@X0P@G>7^___K!`"@X040H.'^___K``!0XP0`
+M`!JX,@/C`S"4YP``4^->0.`#````"@!`H.,$`*#A(-"-XO"!O>CP1RWI`4"@
+MX8!CD.4`,*#C(#"!Y1LPP>6^,M'A,#"#X@(`4^'-``"*!#"1Y0$`<^/*```:
+MN"#1X?\_#^,#`%+AQ@``&B0PT>4#`%/CPP``BEY]AN(X<(?B#%"!X@4`H.$`
+M$`#C`!!`X_[__^L``%#C10``&@`@H.,D.P'C`R"&YP$PH..\)P'C`C"&YU@@
+M@N(",(;G)(#4Y;Y2U.$$`%CC%4#@@[```(H``%7CJP``"@4`5>,%H*"3#:"@
+M@PR0BN()`*#A_O__ZP!04.*E```*!0"@X0`0H.,<(*#C_O__ZPB@A>4`D(7E
+M#0!:XP4PH`.\)P$#`C"&!U@@@@(",(8'`C&(XP0PA>4,H(7B"@"@X3`0A.((
+M()7E_O__ZQPPU.4``%/C!0``"@8`H.$%$*#A_O__ZP``4../```*C```Z@,`
+M6..,``"*7P^(X@`"AN`$`(#B"A"@X0@@E>7^___K!CR(X@,QAN`(()7E!""#
+MY08`H.$'$*#A"""@X0`PH./^___K`$"@XWP``.JX-P'C`S"6YP(`4^-R```:
+M;""6Y0@P`.,!,$#C`S`"X```4^-L```*5PV&XB@`@.+@$(;B_O__ZP"`4.)0
+M```*!0"@X;@1G^7^___K``!0XP`PH!/H,(@5)#L!XP,PEN<&`%/C!`!3$[PW
+M`0,#,)8'[#"(!1PPU.4!`%/C&P``&C!PA.*^(M3A$0Z(X@<0H.$0`%+C$""@
+M(_[__^L%`*#A8!&?Y?[__^L``%#C"@``&O``B.(0$(?B"""@X_[__^L!#(CB
+M&!"'X@@@H./^___K`""@XQ$[`>,#(,;G!@"@X0@0H.$!(*#C_O__ZR0``.HD
+M`-3E``*&X#"`A.*^(M3A!@N`XAP`@.(($*#A$`!2XQ`@H"/^___K)`#4Y0H`
+M@.*XIP'C``**X```AN`$`(#B$!"(X@@@H./^___K)`#4Y0X`@.(``HK@``"&
+MX`0`@.(8$(CB"""@X_[__^L!,*#C$"L!XP(PQN<D$-3EOB]"X@(0AN<&`*#A
+M!Q"@X20@U.7^___K!@"@X?[__^L`0%#B$0``"@4`H.%D$)_E_O__ZP``4.,`
+M,*`3Z#"$%20[`>,#,);G!@!3XP0`4Q,&```:O#<!XP,PEN?L,(3E`$"@XP(`
+M`.H50.#C````Z@!`H.,$`*#A\(>]Z`!`H.,```#J7D#@XP4`H.$)$*#A_O__
+MZ_;__^H4`0``'`$``/!'+>D`D*#A`J"@X0-@H.&V<M/A0'"'X@<`H.'^___K
+M`$"@X0"`H.$``%#C0@``"@`0H.,'(*#A_O__ZP0`H.$#,*#C!#"`Y/\0H.,&
+M(*#C_O__Z[0RUN$#`%/C`_&?ES4``.I`*```-"@``$PH``!8*````%``XP!0
+M0.,'``#J`%``XP!00.,$``#J`%``XP!00.,!``#J`%``XP!00.,,`(CB!1"@
+MX1`@H./^___K`#"6Y00`$^,`,*`3'##(%0`PEN4(`!/C`3"@$QPPR!4&,-KE
+M`3!#XB0PR.4`,);E`@`3XP,```HE`(CB#!"&X@@@H./^___KMC+6X0``4^,$
+M```*OC+(X3``B.(H$(;BMB+6X?[__^L)`*#A"!"@X0<@H.'/_O_K`%"@X00`
+MH.$'$*#A_O__ZP```.H`4.#C!0"@X?"'O>AP0"WI`%"@X0)`H.&`8Y#EMC#2
+MX0,ZH.$C.J#A"@!3XP/QGY<*``#J%"H``!0J```4*@``%"H``&0I``",*0``
+MW"D``!0J```4*@``7"D``!0J``!>0.#C+```Z@`PDN4``%/C`2"@$Q@V`A,#
+M(,87`$"@$P!`H`,8-@(#`T#&!R(``.HD.P'C`S"6YP``4^,=```*`#"2Y0``
+M4^,:```*`2"@XR0[`>,#((;G`$"@X[PW`>,#0(;G%#@!XP-`AN>X-P'C`T"&
+MYR`[`>,#0(;G#@``ZFPPEN4!`!/C!0``"@8`H.'^___K!@"@X?[__^L&`*#A
+M_O__ZP4`H.$`$)3EC/7_ZP!`H.$```#J`$"@XP0`H.%P@+WH\$\MZ1303>(`
+M8*#A`D"@X0`PH.,,,(WE"#"-Y0%0H.$#`%'A`!"@$P$0H`.``%+C`3"@D0$P
+M@8,``%/C!@``"@`@H.,(.0'C`R#`YP(`4>$"0*`1%4#@`\8``.H``%+C`$"@
+M`\,```H$L*#A!`"@X?[__^L`<%#B"T#@`[T```H'`*#A!1"@X0L@H.'^___K
+M`P!4XP!`X)/#``":!%"@X0<`H.$$$*#A#""-X@@PC>+^___K`0!0XP4``!H"
+M(*#CN#<!XP,@AN<$(*#C(#L!XP,@AN<'`*#A!1"@X0P@C>((,(WB_O__ZP$`
+M4.,%```:`B"@X[@W`>,#((;G!R"@XR`[`>,#((;G#%"=Y0%01>(/`%7C!?&?
+MES$``.I\*P``F"L```0L``#L*P``!"P```0L```$+```M"L```0L```$+```
+M!"P```0L```$+```!"P```0L``#0*P```""@XQ0X`>,#((;G`2"@XR0[`>,#
+M((;G&@``Z@$@H.,4.`'C`R"&YP`@H.,D.P'C`R"&YQ,``.H"(*#C%#@!XP,@
+MAN<$(*#C)#L!XP,@AN<,``#J!""@XQ0X`>,#((;G!B"@XR0[`>,#((;G!0``
+MZ@4@H.,4.`'C`R"&YP`@H.,D.P'C`R"&YPA0G>4!4$7B#P!5XP7QGY<R``#J
+M6"P``'0L``#D+```R"P``.0L``#D+```Y"P``)`L``#D+```Y"P``.0L``#D
+M+```Y"P``.0L``#D+```K"P````@H..\-P'C`R"&YP$@H.,D.P'C`R"&YTL`
+M`.H!(*#CO#<!XP,@AN<`(*#C)#L!XP,@AN=$``#J`B"@X[PW`>,#((;G!""@
+MXR0[`>,#((;G/0``Z@0@H..\-P'C`R"&YP8@H.,D.P'C`R"&YS8``.H%(*#C
+MO#<!XP,@AN<`(*#C)#L!XP,@AN<O``#J`""@XP@Y`>,#(,;G`#``XP`P0.,`
+M,)/E!#"-Y2X``.H%@*#A!:"'X``PVN7=`%/C%@``&@(`A>(``(?@!!"-X@0@
+MH./^___K`0!0XP\``!H!0*#C"H"@X00@VN<"((+B`@Q2XP(LH*,,.P'C`R"&
+MYQD,AN()`(#B"A"@X?[__^L(.0'C`T#&YP!`H.,5``#J"("'X`DPV.<",(/B
+M`U"%X'50_^8%`%3AW/__B@!`H.,,``#J!`"@X130C>+PC[WH`""@XP@Y`>,#
+M(,;G`#``XP`P0.,`,)/E!#"-Y0!0H.,!D*#CS?__Z@<`H.$+$*#A_O__Z^[_
+M_^H00"WI@`.0Y0,0H.&T(-+A"___ZQ"`O>CP12WI#-!-X@)0H.$`,*#C!#"-
+MY8!CD.6R,,WA`3#-Y6PPEN4!`!/C`@``&D``$^,``.`#60``"E`QEN46#H;B
+M+1"@XP0@C>(,,$/B_O__ZP!P4.(0```*!$"=Y0``5.,-```*!T"@X0(`C>(%
+M$(?B`B"@X_[__^L",/3E`2#4Y0(T@^'3H.#G8``3XP!PH`,!<*`3`8"@XP(`
+M`.H`<*#C!Z"@X0>`H.$\,=;E`2!#XG(@[^;]`%+C`$"@@PP``(H&(*#A`$"@
+MXP0`H.%_,`/B!`!3X0-`H"$$`,7E/3'2Y0$@@N(!$$/B<1#OYOT`4>/U__^:
+M`0!8XR,``!H&`*#A$Q"@XP$@C>(P-0/C#^"@X0/PEN<!0-WE`P!4XPD``!H`
+M`%KC`P``"@``5^.6<*`3AW"@`PT``.H``%?C2'"@$T%PH`,)``#J``!:XP0`
+M``H.,0#C``!7XP-PH`%+?Z`3`@``Z@``5^.0<*`3@G"@`X=PH.$@,0KC!S!`
+MXY,'`^``,(7E``"@XP0``.H@,0KC!S!`XY,$`^``,(7E``"@XPS0C>+PA;WH
+M<$`MZ2#03>*`8Y#E`$"2Y03@TN4-P*#A,#&?Y0\`D^@'`*SH`##,Y0$`=.,P
+M```*I$*@X<4Z!>-\.D#CDR2#X*,SH.%N`%/C!5"@`RD```H/``"*-P!3XP)0
+MH`,E```*!0``B@H`4^,`4*`#(0``"A0`4^,>```:%0``ZCP`4^,#4*`#&P``
+M"EH`4^,8```:$0``ZO``4^,(4*`#%0``"@4``(IX`%/C!E"@`Q$```JT`%/C
+M#@``&@D``.I:#U/C"5"@`PL```H>#E/C"```&@4``.H!4*#C!@``Z@10H.,$
+M``#J!U"@XP(``.H*4*#C````Z@M0H.,`0*#C#0"@X1`0C>(`P.#C!##0YP4`
+M4^$$P,$7`@``&@0PP><``%[C`@``"@%`A.(-`%3C]?__&@8`H.$0$(WB_O__
+MZP$`4.,``*`#``#@$R#0C>)P@+WH!````/!%+>DLT$WB`E"@X0-@H.&`0Y#E
+M!`"@X?[__^L``%#C2```"L@U`^,#,)3G``!3XT0```JT@-7A(`!8XP9`X(-#
+M``"*;#"4Y1``$^,]```:(#L!XP.@E.>V,-7A``!3XSH```H``%CC.```"B``
+M6.,@@*`C!%"-X@4`H.$`$*#C)""@X_[__^LH<(WB)(`GY00`A>(&$*#A"""@
+MX?[__^N$8(3BA#"4Y7@PA.4$<(?B!@"@X7@0E.7^___K`0!0XQ@```IX4)3E
+M!0"@X2PPD.1X,(3E!Q"@X00@G>7^___K`0!0X_'__QHH()7E!#"=Y0,`4N'M
+M__\:;#"4Y2``$^,#```*>""5Y3@QE.4#`%+AYO__&@0`H.%X$)7E_O__ZP``
+M4.,'```*!`"@X0H0H.'^___K!`"@X000C>+^___K``!0XP$``!H`0.#C````
+MZ@!`H.,$`*#A+-"-XO"%O>CP0"WI#-!-X@)@H.&`0Y#E`#"@XP0PC>5L,)3E
+M00`3XT\```I0,93E%@Z$XBT0H.,$((WB##!#XO[__^L``%#C`'"@`P(```H$
+M4)WE`'!5X@%PH!-/7X3B!0"@X?[__^L!`%#C#0``&@$`5^,%```:!@"@X1`0
+MH.,`(`#C`"!`X_[__^L[``#J!@"@X1`0H.,`(`#C`"!`X_[__^LU``#J!0"@
+MX?[__^L!`%#C#0``&@$`5^,%```:!@"@X1`0H.,`(`#C`"!`X_[__^LI``#J
+M!@"@X1`0H.,`(`#C`"!`X_[__^LC``#J)#&4Y0X`4^,-``":`0!7XP4``!H&
+M`*#A$!"@XP`@`.,`($#C_O__ZQ@``.H&`*#A$!"@XP`@`.,`($#C_O__ZQ(`
+M`.H!`%?C!0``&@8`H.$0$*#C`"``XP`@0./^___K"@``Z@8`H.$0$*#C`"``
+MXP`@0./^___K!```Z@(`H.$0$*#C`"``XP`@0./^___K``"@XPS0C>+P@+WH
+M^$\MZ0-PH.&`0Y#ECC^@X[0PPN$'`*#A`!"@XP,@H.'^___K0#L$XTPP0.,`
+M,(?E9#"@XRPPQ^4M,,?E+C#'Y0<PH.,O,,?E7""@XS`@Q^5-(.#C,2#'Y0!0
+MH.,R4,?E,S#'Y00PH.,T,,?E`#``XP`P0.,`8)/E.&"'Y01@D^4\8(?E"&"3
+MY4!@A^4,8)/E1&"'Y0$\H./`,(?E*CD`X\0PA^6\7<?A%C"@XQ@QQ^40,*#C
+M&3''Y05@H.$*H*#C!)"@XZ"V".,!L$#CK#?4Y0``4^,*```*)H"&XHB!A^`*
+M,,CGK`?4Y?[__^N;``#@"0"(YP$PH..X,,CA`6"&XG9@_^8@`%;C`P``"@%0
+MA>(,0(3B)@!5X^O__QH3/J#CLV"'X3)AQ^4/,*#C-#*'Y3\PH.,/,,?E``"@
+MX_B/O>AP0"WI`E"@X8!#D.5L,)3E`0`3XPH```HD`93E_O__ZZ`V".,!,$#C
+MDP`#X``PA>4!,*#CM##%X20QE.4&,,7E"0``ZJ8'U.7^___KH#8(XP$P0..3
+M``/@`#"%Y0$PH..T,,7AIC?4Y08PQ>4``*#C<("]Z/!/+>G%WTWB`K"@X0-0
+MH.$`,*#C]#*-Y0(LC>*R.\+A%3L(X_\_3^.^/\+A`3"@XP,LC>*P,,+A`PR-
+MX@(`@.(@$(OB!B"@X_[__^L48(7B.#.=Y08`4^$+``":,4Z-XA0@H..T(63A
+M!0"@X000H.$$(*#C_O__ZP0`A>($$(3B$""@X_[__^L&4*#A*`"+XO[__^L`
+M`%#C(```"AL["./_/T_C`BR-XKX_PN$!,*#C`RR-XK8PPN&X<MOA(`!7XR!P
+MH".T<,+A"'"'X@=`A>`X,YWE!`!3X1```)HQ;HWBM'%FX01PH.,%`*#A!A"@
+MX0<@H.'^___K!P"%X`@0AN('(*#A_O__ZP@`A>(L$(OB`SR-XK0@T^'^___K
+M````Z@5`H.&@((OB"""-Y9`PF^4"`*#A+1"@X[TOC>(,,$/B_O__ZP!@4.(4
+M```*]%*=Y0``5>,1```*!E"@X2L.C>("`(#B!1"&X@(@H./^___K`C#UY0$@
+MU>4"-(/ATR#@YR0@C>5@`!/C`#"@`P$PH!,4,(WE`2"@XQ`@C>4#``#J`#"@
+MXQ0PC>4D,(WE$#"-Y0$["./_/T_C`BR-XKX_PN%\4(OB!0"@X?[__^L!`%#C
+M#@``&A`PG>4!`%/C!0``&@,,C>(0$*#C`"``XP`@0./^___K.```Z@,,C>(0
+M$*#C`"``XP`@0./^___K,@``Z@4`H.'^___K`0!0XPX``!H0()WE`0!2XP4`
+M`!H##(WB$!"@XP`@`.,`($#C_O__ZR4``.H##(WB$!"@XP`@`.,`($#C_O__
+MZQ\``.ID,)OE#@!3XPX``)H0,)WE`0!3XP4``!H##(WB$!"@XP`@`.,`($#C
+M_O__ZQ,``.H##(WB$!"@XP`@`.,`($#C_O__ZPT``.H0()WE`0!2XP4``!H#
+M#(WB$!"@XP`@`.,`($#C_O__ZP0``.H##(WB$!"@XP`@`.,`($#C_O__ZQ1@
+MA.(X,YWE!@!3X0L``)HQ7HWB%""@X[0A9>$$`*#A!1"@X00@H./^___K!`"$
+MX@00A>(0(*#C_O__ZP9`H.$'.PCC_S]/XP(LC>*^/\+AE#"+X@PPC>4#`*#A
+M_O__ZP`0H.&^#XWB`@"`X@(@H./^___K`BR-XKH_TN$#`!/C%0``"@$`$^,#
+M,*`3`#.-%0$PH`,`,XT%")"$XC@SG>4)`%/A#```FC%>C>(((*#CM"%EX01@
+MH.,$`*#A!1"@X08@H.'^___K!@"$X`80A>`&(*#A_O__ZP```.H$D*#A9#";
+MY0``4^,!,*`#9#"+!04["./_/T_C`BR-XKX_PN%D`)OE_O__ZZ`V".,!,$#C
+MDP`#X``SC>4!,*#C`RR-XK0PPN%D,)OE!C/-Y0Q0B>(X,YWE!0!3X0L``)HQ
+M3HWB#""@X[0A9.$)`*#A!!"@X00@H./^___K!`")X@00A.(((*#C_O__ZP60
+MH.$K.PCC_S]/XP(LC>*^/\+AND_2X1``%.,".Z`3`RR-$K8PPA$".:`#`RR-
+M`K8PP@$`,*#C`RR-XK0PPN$(4(GB.#.=Y04`4^$1``":,4Z-X@@@H..T(63A
+M!&"@XPD`H.$$$*#A!B"@X?[__^L&`(G@"!"$X@8@H.'^___K!0"@X2P0B^(#
+M/(WBM"#3X?[__^L%D*#AK8^-X@@`H.%`$*#C`"``XP`@0./^___K?"#;Y0``
+M4N,`<*`#(P``"JU/C>(`0(3@"U"@X0!PH.-`@(CB`#``XP`P0.,8,(WE`#``
+MXP-@H.$`8$#C`*``XP"@0.,<D(WE(+"-Y1BPG>4&D*#A?V`"X@<`5N$&<*`A
+M"!!DX*8PH.$!`!+C"2"@`0L@H!$`((WE!`"@X0H@H.'^___K?2#5Y0%0A>(`
+M`%+C`$"$$.[__QH<D)WE(+"=Y1`@G>4!`%+C+P``&@(LC>*R.]+A`@D3XPP`
+M``HD,)WE``!3XP0```H.<0#C%""=Y0``4N-+?Z`3(@``ZA0PG>4``%/CD'"@
+M$X)PH`,=``#J@``3XPH```HD()WE``!2XP,```H4,)WE``!3XQ0``!H/``#J
+M%""=Y0``4N,.```:"0``ZB0PG>4``%/C`P``"A0@G>4``%+C"0``&@0``.H4
+M,)WE``!3XP,``!I!<*#C!```ZH=PH.,"``#J2'"@XP```.J6<*#CAW"@X2$[
+M"./_/T_C`BR-XKX_PN$`,*#C!3/-Y00SS>4@,0KC!S!`XY,'`^``,XWE#%")
+MXC@SG>4%`%/A"P``FC%.C>(,(*#CM"%DX0D`H.$$$*#A!""@X_[__^L$`(GB
+M!!"$X@@@H./^___K!9"@X0`PH.,"+(WBL#O"X;PZPN&0$)OE2S^-X@`PC>4K
+M/HWB!#"-Y0P`G>4L((WBJS^-XO[__^L"/(WBL$O3X0``5.-A```*BT^-X@0`
+MH.$`$*#C@""@X_[__^L`,`#C`#!`XP,`D^@#`(3H`BR-XK!+TN$``%3C$```
+M"B-NC>(#8(;B`$"@XP!P`.,`<$#C2X^-X@10H.$&`*#A!Q"@X04@V.?^___K
+M`&"&X`%0A>("/(WBL$O3X04`5.'U__^*OP^-X@`0H.,4(*#C_O__ZP(\"./_
+M/T_C`BR-XKX_PN&+#XWB_O__ZW``_^8#/(WBM`##X0A0@.(%8(G@.".=Y08`
+M4N$0``":,4Z-XK119.$$4*#C"0"@X000H.$%(*#A_O__ZP4`B>`($(3B!2"@
+MX?[__^L(`(GBBQ^-X@,\C>*T(-/A_O__ZP:0H.&_#XWB`!"@XQ0@H./^___K
+M!3P(X_\_3^,"+(WBOC_"X;!;TN$#/(WBM%##X0A0A>(%8(G@.".=Y08`4N$0
+M``":,4Z-XK119.$$4*#C"0"@X000H.$%(*#A_O__ZP4`B>`($(3B!2"@X?[_
+M_^L(`(GB2Q^-X@,\C>*T(-/A_O__ZP:0H.$"+(WBO$K2X0``5.-A```*BT^-
+MX@0`H.$`$*#C@""@X_[__^L`,`#C`#!`XP,`D^@#`(3H`CR-XKQ*T^$``%3C
+M$```"B-NC>(#8(;B`$"@XP!P`.,`<$#C+("-X@10H.$&`*#A!Q"@X04@V.?^
+M___K`&"&X`%0A>("+(WBO$K2X04`5.'U__^*OP^-X@`0H.,4(*#C_O__ZP(\
+M"./_/T_C`BR-XKX_PN&+#XWB_O__ZW``_^8#/(WBM`##X0A0@.(%8(G@.".=
+MY08`4N$0``":,4Z-XK119.$$4*#C"0"@X000H.$%(*#A_O__ZP4`B>`($(3B
+M!2"@X?[__^L(`(GBBQ^-X@,\C>*T(-/A_O__ZP:0H.&_#XWB`!"@XQ0@H./^
+M___K!3P(X_\_3^,"+(WBOC_"X;Q:TN$#/(WBM%##X0A0A>(%8(G@.".=Y08`
+M4N$0``":,4Z-XK119.$$4*#C"0"@X000H.$%(*#A_O__ZP4`B>`($(3B!2"@
+MX?[__^L(`(GB+!"-X@,\C>*T(-/A_O__ZP:0H.$`,*#CK#*-Y9"`F^4,@$CB
+M`P!8X0`PH-,!,*##"""=Y0``4N,``%@3.P``V@``4^,Y```*`$"@XZNOC>(%
+M/`CC_S]/XPPPC>6_+XWB""""XA`@C>4$4*#A%+"-Y0BPH.$(@)WE!7"@X05@
+MB.`&`*#A"A"@X?[__^L``%#C'P``"JQ"G>4"`%3C'```F@PPG>4"+(WBOC_"
+MX;PZTN$#+(WBM##"X0@P@^((,(WE`T")X#@SG>4$`%/A$```F@@@G>4"/(WB
+MO"_#X0D`H.&_'XWB!""@X_[__^L$`(GB$!"=Y00@H./^___K"`")X@80H.$#
+M/(WBM"#3X?[__^L$D*#A!W"(X`$PU^4",(/B`U"%X`4`6^'2___*%+"=Y0$\
+M"./_/T_C`BR-XKX_PN%+,*#C`S/-Y5`PF^4!,\WEC##;Y0`SS>5C,.#C`C/-
+MY0A@B>(X,YWE!@!3X0P``)HQ3HWB"""@X[0A9.$$4*#C"0"@X000H.$%(*#A
+M_O__ZP4`B>`%$(3@!2"@X?[__^L&D*#A"0"@X<7?C>+PC[WH\$\MZ1S03>(4
+M$(WE#""-Y1`PC>6`DY#EM'#2X0=P@^#$,@/C`S#9YP``4^,$```*B#4#XP,P
+MF><``%/C%4#@$S8``!K^___K#2"@X7\]PN,_,,/C!""3Y0$@@N($((/EA(")
+MXH1`F>5ZOHGB#+"+XA!@G>7_H@#C"`"@X000H.'^___K`0!0XQ8```H',&;@
+M"@!3X09`X-,3``#:!%"@X2@PE.4``%/C`$"4!?'__PH+`*#A9!"5Y?[__^L!
+M`%#C!@``&@!PC>4)`*#A%!"=Y04@H.$&,*#AU?S_ZP!@H.$`0)3EX___Z@!`
+MH.,-(*#A?SW"XS\PP^,$()/E`2!"X@0@@^7^___K$#"=Y09@8^`,()WEM&#"
+MX0`PH..V,,+A!`"@X1S0C>+PC[WH<$`MZ8!3D.4`0%/B#P``"K`PU.$``%/C
+M`P``"@$`4^->0.`3#```&@0``.H%`*#A_O__ZP``4.,$```*!0``Z@4`H.'^
+M___K``!0XP$``!H`0.#C````Z@!`H.,$`*#A<("]Z/!'+>D"8*#A@$.0Y00`
+MH.'^___K``!0XP0``!KP`)_E\!"?Y?[__^L`0.#C-@``ZL@U`^,#,)3G``!3
+MXR\```JP,-;A`0!3XP0```K(`)_EP!"?Y?[__^L50.#C*@``ZB`[`>,#H)3G
+MA'"$XH0PE.5X,(3E`F"&X@:`H.,'`*#A>!"4Y?[__^L!`%#C!0``&@0`H.$&
+M$*#A_O__ZP``4.,6```*%P``ZGA0E.4%`*#A(#"0Y'@PA.4&$*#A"""@X?[_
+M_^L!`%#CZ___&@0`H.%X$)7E_O__ZP``4.,'```*!`"@X0H0H.'^___K!`"@
+MX080H.'^___K``!0XP$``!H`0.#C````Z@!`H.,$`*#A\(>]Z/0!```4````
+M$`(``#!`+>D4T$WB`%"@X0U`H.$-`*#A`!"@XQ`@H./^___K`3"@X[`PS>$"
+M`(WB`!"@XP8@H./^___KUSV@XP,`E><5&PCC#2"@X0`PH./^___K%-"-XC"`
+MO>@P0"WI%-!-X@!0H.$-0*#A#0"@X0`0H.,0(*#C_O__ZP$PH..P,,WA`@"-
+MXN`0A>(&(*#C_O__Z]<]H.,#`)7G%1L(XPT@H.$`,*#C_O__ZQ30C>(P@+WH
+M,$`MZ1303>(`4*#A#4"@X0T`H.$`$*#C$""@X_[__^O7/:#C`P"5YQD;".,-
+M(*#A`#"@X_[__^L4T(WB,("]Z/!/+>DLT$WB`F"@X0-0H.&`0Y#E!`"@X?[_
+M_^L``%#C@@``"H@U`^,#,)3G``!3XWX``!K(-0/C`S"4YP``4^-Z```*G34#
+MXP,PU.<``%/C=@``"A0UU.4!`%/C`P``&@0`H.'^___K`$"@XW```.IL,)3E
+M(@T3XP,```H$`*#A_O__ZP!`H.-I``#JM##6X4\/4^,?```:MC#6X0(`$^-B
+M```*`6#5Y2``5N,@8*"C!'"-X@<`H.$`$*#C)""@X_[__^L$`(?B%!"%X@8@
+MH.'^___K!&"-Y?[__^L-,*#A?UW#XS]0Q>,$,)7E`3"#X@0PA>4$`*#A!Q"@
+MX?[__^L`0*#A!#"5Y0$P0^($,(7E_O__ZT(``.H+`%/C/0``F@4`H.$4$9_E
+M#""@X_[__^L!`%#C-P``&K1PUN$,<$?B#&"%X@0`C>(`$*#C)""@X_[__^OH
+M@)_E`Z"-X@*0C>((L(WB&0``Z@8`H.$($*#A"B"@X?[__^L#4-WE4P!5XQ0`
+M`!H!8(;B`7!'XL=?Q^$&`*#A"!"@X0D@H.'^___K`6"&X@%01>("(-WE`@!5
+MX0,``+H$((WE"P"@X080H.'^___K`G#=Y0=@AN`%<&?@``!7X^/__\K^___K
+M#3"@X7]=P^,_4,7C!#"5Y0$P@^($,(7E!`"@X000C>+^___K`$"@X00PE>4!
+M,$/B!#"%Y?[__^L"``#J!`"@X?[__^L`0*#A``!4XP!`H!,````:`$#@XP0`
+MH.$LT(WB\(^]Z"0````X`@``\$\MZ5G?3>(`L*#A$!"-Y0*`H.$4,(WE@).0
+MY;1@TN$&H*#A!@"@X?[__^L`4%#B"T#@`W0!``H`$)CE#0"@X7\]P.,_,,/C
+M"'"3Y09`D>`'0-0P`'"@,P``5^,%```:!0"@X08@H.'^___K``!0XPH```H$
+M``#J``!6XP<```H%`*#A!A"@X?[__^L%`*#A"A"@X?[__^L-0.#C6@$`ZK8@
+MV.%F-PCC`P!2X0`PH!,!,*`#"`!6XP`PH-,``%/C%@``"@`P`.,`,$#C-#"3
+MY3PPC>4`,-7EW0!3XT8!`!H"`(7B/!"-X@0@H./^___K`0!0XT`!`!H"#%;C
+M`FR@HU4.B>(#`(#B!1"@X08@H.'^___K5&>)Y0!`H.,W`0#J"P!6XP,``,H`
+M`%;C`$"@PPT``,H5``#J!0"@X=04G^4,(*#C_O__ZP$`4./U__\:"P"@X1`0
+MG>4((*#A!3"@X13__^L`0*#A)`$`Z@0PU>=A($/B<B#OYAD`4N,@,$.2!##%
+MEP%`A.($`%;A]O__R@!`H..`9)_E!'&6YP<`H.'^___K`""@X04`H.$'$*#A
+M_O__ZP``4.,#```*`4"$X@D`5./S__\:[0``Z@@`5.,$\9^7Z@``ZCA)````
+M2@``C$H``,Q*```82P``6$L``'A+``"82P``7$P``````.,``$#C_O__ZP`P
+M`.,`,$#C%$"3Y0$`5.,$```:`T"@X1@`@^+^___K`C"@XQ0PA.4`,`#C`#!`
+MXP!`D^4``%3C"0``&M1SG^5]GZ#CT&.?Y0<`H.'^___K"0"@X?[__^L`0);E
+M``!4X_C__PI<,(WB`"``XP`@0.,#`)+H`R"@X00`@N2P$,+A\"X/X_\O3^,%
+M$*#C%@Z-XK(0@.$+`*#A`AP(XTP@C>+^___K!0"@X0`0`.,`$$#C`R"@X_[_
+M_^NT``#J````XP``0./^___K7#"-X@`@`.,`($#C`P"2Z`,@H.$$`(+D`!#"
+MY?`N#^/_+T_C!!"@XQ8.C>*R$(#A"P"@X0(<".-,((WB_O__ZP4`H.$`$`#C
+M`!!`XP,@H./^___K`#``XP`P0.,40)/E`@!4XY<``!H#0*#A&`"#XO[__^L!
+M,*#C%#"$Y9$``.IL,)GE`0`3XP8```H%`*#A`!``XP`00..*-0'CTR"9X?[_
+M_^N'``#J!0"@X0`0`.,`$$#C`R"@X_[__^N!``#J"P"@X1`0G>4L((WB%#"=
+MY<3X_^L``%#C`$"@$RP@G06#/@T#&S-$`Y,2PP#"+Z`!0TEB``4`H.$`$`#C
+M`!!`XP0@H.'^___K;@``ZG01F^4`(-'E`3#1Y0(`T>4``(WE`P#1Y00`C>4$
+M`-'E"`"-Y040T>4,$(WE!0"@X0`0`.,`$$#C_O__ZUX``.H!,*#C4C7)Y04`
+MH.$`$`#C`!!`XP,@H./^___K5@``Z@`PH.-2-<GE!0"@X0`0`.,`$$#C`R"@
+MX_[__^M.``#J/$"-X@4`H.$`$`#C`!!`XP0@H.'^___K!`"@X0`0`.,`$$#C
+M_O__ZP``4.,`,*`#2#"-!0X```H\`(WB`!``XP`00./^___K``!0XP(PH`-(
+M,(T%!@``"CP`C>(`$`#C`!!`X_[__^L``%#C!3"@`T@PC04`,`#C`#!`XTA`
+MG>4`0,/E'$"-X@0`H.%($(WB!""@X_[__^L+`*#A$!"=Y00@H.$4,)WE[?+_
+MZP4`H.$`$`#C`!!`XP,@H./^___K'0``Z@`P`.,`,$#C`##3Y0``4^,%```*
+M`@!3XPU`H`,#```*!0!3XPY`H`,````*"T"@XP4`H.$`$`#C`!!`XP0@H.'^
+M___K`#``XP`P0.,```#C``!`XP00H.$`(-/E_O__ZP0``.H%`*#A`!``XP`0
+M0.,#(*#C_O__ZP"0F.6T0-CA!0"@X?[__^L!<(#B=W#_Y@<`5.$$<*`Q#2"@
+MX7\]PN,_,,/C"&"3Y0=`F>`&0-0P`&"@,P``5N,$```:"0"@X040H.$'(*#A
+M_O__ZP!PH.$``%?C#4#@$P```!H`0*#C!0"@X0H0H.'^___K!`"@X5G?C>+P
+MC[WH)````#````!@`@```````'!`+>D"4*#A@$.0Y00`H.'^___K``!0XP!`
+MH`,?```*G34#XP,PU.<``%/C&@``"@`PE>4#`%/C`_&?EP,``.K$30``O$T`
+M`-1-``#,30``%4#@XQ$``.H`4*#C!```Z@)0H.,"``#J!%"@XP```.H!4*#C
+M!`"@X040H.'^___K``!0XP0```H$`*#A!1"@X?[__^L`0*#C````Z@!`X.,$
+M`*#A<("]Z/!'+>D`D*#A`:"@X0)PH.$#@*#A'`"@X_[__^L`4*#A`$"@X0``
+M4.,`0*`#*@``"A0`H./^___K`&!0X@0``!H%`*#A'!"@X_[__^L`0*#C(0``
+MZ@8`H.$`$*#C%""@X_[__^L!@,;E`'#&Y0$PH.,#,,;E`7!'XG=P[^8$`%?C
+M$%"@@P`P`),`,$"3!W"#D#A0UY4$`(;B"A"@X04@H.'^___K%#"@X[`PQ.$$
+M8(3E"#"$Y0`PH.,,,(3E$#"$Y10`A.+^___K2PV)XA@`@.($$*#A_O__ZP!`
+MH.$$`*#A\(>]Z!!`+>D%($+B<B#OY@@`4N,`0*"#`,``DP#`0),"((R00$#2
+ME00@H.&[___K$("]Z/!/+>D4T$WB`&"@X0%0H.'\.PCC`P!2X9L```K^.PCC
+M`P!2X5Y`X!.J`P`:M`'1X3\`4..1``":$#"1Y0``4^..```*_O__ZP"`H.$`
+MH*#A``!0XPM@X`.)```*$!"5Y;21U>$-(*#A?SW"XS\PP^,(<)/E"4"1X`=`
+MU#``<*`S``!7XP0``!H)(*#A_O__ZP``4.,)```*`P``Z@``6>,&```*"1"@
+MX?[__^L(`*#AM!'5X?[__^L-8.#C<```Z@`PFN4!,$/B`P!3XP/QGY<#``#J
+M#%```,10``#<4```]%```%Y@X.--``#J$!":Y8!#EN4,,-KE!P!3XP@``(K<
+M,-KA`2"@XQ(SH.'<`!/C(0``&B``$^,;```:`@`3XP$``!I>8.#C/0``Z@(@
+MH..X-P'C`R"$Y_\0`>(!`%'C`@``"@(`4>$3```:!@``Z@0PH.,@*P'C`C"$
+MYR0K`>,",(3G`&"@XRT``.H'(*#C(#L!XP,@A.<&(*#C)#L!XP,@A.<`8*#C
+M)0``Z@8`H.'BZ__K`&"@X2$``.H`8*#C'P``ZH`#EN4P$(KBO"#:X5+V_^L`
+M8*#A&0``Z@8`H.$*$*#AM"'5X<[T_^L`8*#A$P``ZH!#EN4,,)KE`0!3XP,`
+M``H"`%/C7F#@$PP``!H$``#J!`"@X?[__^L``%#C!```&@4``.H$`*#A_O__
+MZP``4.,!```*`&"@XP```.H`8.#C``!6XQ```!H0`)7EM)'5X0T@H.%_/<+C
+M/S##XPAPD^4)0)#@!T#4,`!PH#,``%?C`P``&@H0H.$)(*#A_O__ZP"0H.$`
+M`%GC#6#@$P@`H.&T$=7A_O__ZP```.H58.#C!D"@X1(#`.J`([;EG34#XP,P
+MTN<``%/C`$#@`PP#``H0,)'E``!3XQ5`X`,(`P`*M`'1X?[__^L`L*#A`'"@
+MX0``4.,+0.`#`0,`"A`0E>6T@=7A#2"@X7\]PN,_,,/C"*"3Y0A`D>`*0-0P
+M`*"@,P``6N,$```:"""@X?[__^L``%#C"0``"@,``.H``%CC!@``"@@0H.'^
+M___K"P"@X;01U>'^___K#4#@X^@"`.H`,)?E`3!#XA(`4^,#\9^7$@``ZKQ2
+M``#84@``M%,``+12``",6P``@%0``+12``"T4@``M%(``+12``"T4@``M%(`
+M`+12``"T4@``M%(``!A4```<7```O%P``#!=``!>0.#CN`(`Z@!`EN4$`*#A
+M_O__ZP0`H.'^___K`$"@X;$"`.H`8);E;#"6Y1$`$^,P```*!#"7Y0$`<^,#
+M```:N"#7X0$X@^(#`%+A*0``"E<-AN(H`(#B!!"'XO[__^L`0%#B"T#@`Y\"
+M``H0@)?EO##7X=0PA.43#H3B%!"'XA`@H./^___K`@P8XP$PH!/<,(05`#"@
+M`]PPA`7(-);E``!3X]PPA`4""QCC`#"@`UPVA`4'```*`3"@XUPVA.7<,(3E
+M9PZ$X@4`@.(D$(?B&B"@X_[__^O4-);E``!3XUPVA`4&`*#A!!"@X?[__^L`
+M0*#C?`(`ZA5`X.-Z`@#J`&"6Y6PPEN41`!/C$@``"@0PE^4!`'/C`P``&K@@
+MU^$!.(/B`P!2X0L```I7#8;B*`"`X@00A^+^___K`$!0X@!`H`-H`@`*!@"@
+MX000H.'^___K`$"@XV,"`.H50.#C80(`ZK2!U>$`8);E;#"6Y1``$^,2```*
+ML$<!XP0`AN`,$(?B`B"@X_[__^NT,);A`3!#XG,P_^8?`%/C!#"@@2`@H(.S
+M((:!!@"@X0X0A^(.($CB_O__ZP$`4.,`0*`#20(`"A5`X.-'`@#JM"'5X0!@
+MEN4`,*#C(#"'Y1LPQ^6^,M?A0#"#X@,`4N%A`@`:!#"7Y0$`<^,'```:N"#7
+MX0$X@^(#`%+A`P``&B0PU^4#`%/C5P(`B@8``.I7#8;B*`"`X@00A^+^___K
+M`(!0XD8"`!I-`@#J#$"'X@0`H.$X&9_E_O__ZP``4.-'`@`*!`"@X2@9G^7^
+M___K`0!PX@``H#,``%#C`("@`P$PH`-2```*)(#7Y;ZBU^$!,'KB`#"@,P,`
+M6.,!,(.#``!3XS@"`!H``%KC`$"@`PT```H%`%KC!:"@DPV@H(,,D(KB"0"@
+MX?[__^L`0%#B*P(`"@0`H.$`$*#C'""@X_[__^L(H(3E`)"$Y02`A.4,D(3B
+M"0"@X3`0A^((()3E_O__ZQPPU^4``%/C(```"@`@H.,D.P'C`R"&YP$PH..\
+M)P'C`C"&YU@@@N(",(;G"#"4Y0T`4^,%,*`#6"!"`@(PA@=8((("`C"&!U\]
+MH.,#@(;G7P^(X@`"AN`$`(#B"1"@X0@@E.7^___K!CR(X@,QAN`(()3E!""#
+MY08`H.$,$(3B""#4Y0@PH.$O_O_K3@$`ZE\/B.(``H;@!`"`X@D0H.$(()3E
+M_O__ZP8\B.(#,8;@"""4Y00@@^4&`*#A#!"$X@@@U.4(,*#A'_[_ZSX!`.H`
+M`%/C;@``"FPPEN40`!/C:P``"APPU^4!`%/CXP$`&@``4.,1```*)`#7Y0`"
+MAN"^(M?A!@N`XAP`@.(P$(?B$`!2XQ`@H"/^___K`2"@XQ0X`>,#((;GOC+7
+MX0T`4^,$((("%#@!`P,@A@<[``#J!`"@X4P7G^7^___K``!0XR$``!H"(*#C
+M%#@!XP,@AN<D`-?E``*&X#!`A^*^(M?A!@N`XAP`@.($$*#A$`!2XQ`@H"/^
+M___K)`#7Y0H`@.*XAP'C``*(X```AN`$`(#B$!"$X@@@H./^___K)`#7Y0X`
+M@.(``HC@``"&X`0`@.(8$(3B"""@X_[__^L!(*#C$3L!XP,@QN<4``#J!`"@
+MX;06G^7^___K``!0XPP``!H$(*#C%#@!XP,@AN<D`-?E``*&X+XBU^$&"X#B
+M'`"`XC`0A^(0`%+C$""@(_[__^L"``#J`""@XQ0X`>,#((;G)"#7Y1@X`>,#
+M((;G`2"@X[X_@^(#(,;GOS]#X@,@EN=8,$/B`R"&YP8`H.$P$(?B<B#OYB0P
+MU^5^_?_K!@"@X?[__^L`@%#B@`$`"@!`H./H0(CE%#@!XP,PEN?L,(CE60$`
+MZK@W`>,#,);G`@!3XP`PH!,!,*`#``!8XP`PH`,``%/C<0$`"FPPEN40`!/C
+M;@$`"APPU^4!`%/C50``&C"@A^*^(M?A$0Z(X@H0H.$0`%+C$""@(_[__^L$
+M`*#AG!6?Y?[__^L``%#C!@``&@$PH./L,(CEOC+7X0T`4^,%,*`#[#"(!1H`
+M`.H$`*#A<!6?Y?[__^L``%#C#0``&@(PH./L,(CE\`"(XA`0BN(((*#C_O__
+MZP$,B.(8$(KB"""@X_[__^L!(*#C$3L!XP,@QN<'``#J!`"@X2@5G^7^___K
+M``!0XP0PH`/L,(@%`#"@$^PPB!4<`*#C_O__ZP"0H.$``%#C'P``"A<`H./^
+M___K`*!0X@,``!H)`*#A'!"@X_[__^L7``#J%`")XO[__^L5,*#CL##)X02@
+MB>47,*#C"#")Y0`PH.,,,(GE$#")Y>PPF.4&,,KE"@"@X>`0B.(&(*#C_O__
+MZP<`BN(1'HCB$""@X_[__^M+#8;B&`"`X@D0H.'^___K`$"@X^A`B.7T``#J
+M``!0XQ$```HD`-?E``*&X+XBU^$&"X#B'`"`XC`0A^(0`%+C$""@(_[__^L!
+M(*#C%#@!XP,@AN>^,M?A#0!3XP0@@@(4.`$#`R"&!SL``.H$`*#A%!2?Y?[_
+M_^L``%#C(0``&@(@H.,4.`'C`R"&YR0`U^4``H;@,$"'XKXBU^$&"X#B'`"`
+MX@00H.$0`%+C$""@(_[__^LD`-?E"@"`XKB'`>,``HC@``"&X`0`@.(0$(3B
+M"""@X_[__^LD`-?E#@"`X@`"B.```(;@!`"`XA@0A.(((*#C_O__ZP$@H.,1
+M.P'C`R#&YQ0``.H$`*#A?!.?Y?[__^L``%#C#```&@0@H.,4.`'C`R"&YR0`
+MU^4``H;@OB+7X08+@.(<`(#B,!"'XA``4N,0(*`C_O__ZP(``.H`(*#C%#@!
+MXP,@AN<D(-?E&#@!XP,@AN<!(*#COC^#X@,@QN>_/T/B`R"6YU@P0^(#((;G
+M!@"@X3`0A^)R(._F)##7Y;#\_^L&`*#A_O__ZP"`4.*R```*`$"@X^A`B.44
+M.`'C`S"6Y^PPB.6+``#J``!4XXD```H$`*#A#!"*XO[__^L`0*#CA```Z@!`
+MEN5L,)3E$0`3XQT```H$,)?E`0!SXP,``!JX(-?A`3B#X@,`4N$6```*5PV$
+MXB@`@.($$(?B_O__ZP!`4.(`0.`#<@``"DPWU.7=`%/C,`!3$P!`H!-M```:
+M32?4Y0(@@N(@`%+C(""@(PP@A^40`(?B'1V$X@P0@>+^___K`$"@XV(``.H5
+M0.#C8```ZK0QU>$<(I_E3""2Y0P@C>4`0);E;""4Y1``$N,=```*#F!#XG@'
+ME.4``%#C`P``"H07E.7^___K`#"@XW@WA.4``%;C`$"@TTT``-H&`*#A_O__
+MZW@'A.6$9X3E``!0XPP```H.$(?B!B"@X?[__^L$`*#AW1"@XPP@C>(!,*#C
+M_O__ZP$@H./0,@'C`R#$YP!`H.,Z``#J%4#@XS@``.JT,=7A`$"6Y6P@E.40
+M`!+C%0``"@Y@0^)\!Y3E``!0XP,```J(%Y3E_O__ZP`PH.-\-X3E``!6XP!`
+MH-,H``#:!@"@X?[__^M\!X3EB&>$Y0``4.,$```*#A"'X@8@H.'^___K`$"@
+MXQT``.H50.#C&P``ZK0QU>$`0);E;""4Y1``$N,5```*#F!#XH`'E.4``%#C
+M`P``"HP7E.7^___K`#"@XX`WA.4``%;C`$"@TPL``-H&`*#A_O__ZX`'A.6,
+M9X3E``!0XP0```H.$(?B!B"@X?[__^L`0*#C````ZA5`X.,``%3C$```&A``
+ME>6T8=7A#2"@X7\]PN,_,,/C"("3Y08PD.`(,-,P`("@,P``6.,#```:!Q"@
+MX08@H.'^___K`&"@X0``5N,-0.`3"P"@X;01U>'^___K!`"@X130C>+PC[WH
+M#$"'X@0`H.$D$)_E_O__ZP$`<.(``*`S`#"@XQ/^_^H`0*#CW/__ZA5`X./:
+M___J%`$``!`!```<`0``)`$````````00"WI`$``XP!`0.,`,*#C%#"$Y60`
+MH./^___K%$"4Y0(`5.,!```:#`"?Y?[__^L$`)_E_O__ZQ"`O>@8````<$`M
+MZ0!``.,`0$#C&%"$X@4`H.$`$*#C`"``XP`@0./^___K!0"@X?[__^L",*#C
+M%#"$Y7"`O>A`0@\`@(0>`&#L4P#`V*<`@(U;`$!4B0``&[<`@*@2`0`V;@$`
+M424"`&S<`H#Y-P.(`@``N`(``'@#``"``P``C`,``)0#``"@`P``L`,``+@#
+M``!L````.``<`!4```!,`0``4```````````````````````````````````
 M````````````````````````````````````````````````````````````
 M````````````````````````````````````````````````````````````
 M````````````````````````````````````````````````````````````
@@ -548,445 +549,445 @@ M````````````````````````````````````````````````````````````
 M````````````````````````````````````````````````````````````
 M````````````````````````````````````````````````````````````
 M````````````````````````````````````````````````````````````
-M`````````"BR`8&PL%^$``````````"PL+"`0````+"PH(```0``L+"P@`@!
-M``"PL+"`6`$``+"PH("H`0``L+"P@.P!``"PL+"`"`(``+"PH(!<`@``L+"P
-M@'@"``"PL+"`E`(``+"PL("L`@``L*@!@.0"``"PL+"`[`(``+"PL(#T`@``
-ML+"P@/P"``"PL+"`!`,``+"PL(`,`P``L+"P@!0#``"PL**`?`,``+"PL("$
-M`P``L+"P@(P#``"PL+"`E`,``+"PL("8`P``L+"P@)P#``"PK@&`)`0``+"P
-ML(`L!```L+"@@*@$``"PL*J`\`0``*\HLH!X"P``L*P!@*0,````````3!``
-M`+"K!(``$@``L+"H@,P2``"PK`&`;!0``+"PJ("$%```L*P#@-P7``"PL*B`
-M!!@``+"O#H"L&@``L*X!@"P=``"PL*J`8!T``+"N`X"('P``L+"J@/0@``"P
-ML*B`*"$``+"PJH!X(0``L+"J@.0A``"PK`>`%"0``+"PKH"H)P``L+"N@/`H
-M``"PL*J`""H``+"O!(#$+0``L+"H@-PM``!?A`*`A"\``+"J!X#8,```7X0*
-M@#@R``"PJP*`O#,``*\(L8#\-```L+"J@'`U``"O1+*`/$$``+"O!H!H0@``
-ML+"J@,Q"``"PL*Z`[$,``+"I!(!$1```L*D$@)Q$``"PJ02`W$0``+"O"H`D
-M1P``KS\8@$Q-``"PL*J`]$T``+"PKH#43@``L+"H@`1/``"PKP2`'%X``+"P
-MJ(!<7@``L+"J@`!0\@0+"@D(!P8%!`,"`0#_````<G1W7W=X7W-E=%]W87``
-M`$-30T%.(%,!``!3````````4/($!1`0$`T````!``````````4`````4/($
-MX(L```)(``!R='=?=W)I=&4S,@``````X8L```%($"AR='=?<F5A9#,R````
-M````XHL```````!D<FEV97)?97AT````````XXL`````````````````````
-M````````Y(L```%(``!A<&EN9F\`````````````Y8L```)(``!S971P:60`
-M````````````YHL```%(``!W<'-?<W1A<G0`````````YXL```%(``!G971?
-M<V5N<VET:79I='D`Z(L```%(``!W<'-?<')O8E]R97%?:64`Z8L```%(``!W
-M<'-?87-S;V-?<F5Q7VEEZHL```%(``!C:&%N;F5L7W!L86X`````ZXL```)(
-M``!D8F<`````````````````[(L```-(``!R9G<`````````````````[8L`
-M``)($"AR9G(`````````````````\(L``$`@``!P,G!?<V5T````````````
-M\8L``$`@0"AP,G!?9V5T````````````\HL``$`@$"!P,G!?9V5T,@``````
-M````]HL``$`@``!P;5]S970`````````````^(L``!`@``!R97)E9U]N9%]N
-M86UE````^HL``(`@``!E9G5S95]S970`````````^XL``(`@`"]E9G5S95]G
-M970`````````,'@E,#5X```L````<F5A;&UA<``E<R`*`````"5S(`DP>"4P
-M,G@)`"5S("4P,E@`)7,)`"5S"@!R;6%P`````"5S(#!X)3`R6````"5S(`!R
-M96%L<F%W`"5S("4P,G@`)7,*"0````!M86,`=FED<&ED``!A8FQE<F%W`"5S
-M(#H@6R!A=F%I;&%B;&4@<F%W('-I>F5=(#T@)60`)7,@.B!#;VUM86YD(&YO
-M="!F;W5N9`H`=VUA<`````!W<F%W`````$-O;6UA;F0@;F]T(&9O=6YD"@``
-M9&ES86)L925D````;'!S/0````!I<',]`````"5U```P>"4P.'@``#Q7249)
-M0%)%04Q414L^``!715``;F]N90````!42TE0`````$-#35``````245%12`X
-M,#(N,3%B;@```$E%144@.#`R+C$Q8@````!)145%(#@P,BXQ,6)G;@``245%
-M12`X,#(N,3%B9P```$E%144@.#`R+C$Q86X```!)145%(#@P,BXQ,6$`````
-M245%12`X,#(N,3%G;@```$E%144@.#`R+C$Q9P````!U;F%S<V]C:6%T960`
-M````(%)A=&5S("A-8B]S*3H@```````N-0``)60E<R````!W<&%?:64]`"4P
-M,G@`````<G-N7VEE/0`E<SH@<F9P=W)S=&%T95]C:&5C:R!F86EL+@H`)7,Z
-M('1E;7`M/G-A7V9A;6EL>2`A/2!!4E!(4D1?151(15(N"@```"5C``!!3D12
-M3TE$7U=)1DE?0TU$7U-405)4+BXN+BXN+BXN+@H```!W86ET:6YG(&9O<B!W
-M:69I(&1R:79E<B!T;R!B92!R96%D>2XN+@H`4U1!4E0```!/2P``04Y$4D])
-M1%]7249)7T--1%]35$]0+BXN+BXN+BXN+@H`````4U1/4`````!7249)(')S
-M<VD@)60`````3$E.2U-0145$("5D`````$U!0T%$1%(@/2`E,#)X.B4P,G@Z
-M)3`R>#HE,#)X.B4P,G@Z)3`R>``E*G,@)7,``%53``!%50``2E```%-C86XM
-M0VAA;FYE;',@/2`E9```1V5T($-H86YN96QS(')E='5R;B`E9"`H:6YI=%]C
-M:&%N;F5L7W!L86X])60I"@``<G1L.#$X.%]W:69I7W=A:V5L;V-K````4E-3
-M20````!,24Y+4U!%140```!-04-!1$12`%-#04XM04-4259%`%-#04XM4$%3
-M4TE610````!#3U5.5%)9`%-#04XM0TA!3DY%3%,`````1T-#.B`H1TY5*2`T
-M+C0N,`!!*@```&%E86)I``$@````!3<M00`&"@=!"`$2!!0!%0$7`Q@!&0$:
-M`AX!`"YS>6UT86(`+G-T<G1A8@`N<VAS=')T86(`+G)E;"YT97AT`"YR96PN
-M9&%T80`N8G-S`"Y!4DTN97AT86(`+G)E;"Y!4DTN97AI9'@`+G)O9&%T80`N
-M<F]D871A+G-T<C$N-``N8V]M;65N=``N;F]T92Y'3E4M<W1A8VL`+D%232YA
-M='1R:6)U=&5S````````````````````````````````````````````````
-M````````'P````$````&`````````#0```"47@`````````````$````````
-M`!L````)``````````````",D```2!@```\````!````!`````@````I````
-M`0````,`````````R%X``+P!``````````````0`````````)0````D`````
-M`````````-2H``"(`@``#P````,````$````"````"\````(`````P``````
-M``"(8```8```````````````"``````````T`````0````(`````````B&``
-M``P```````````````0`````````0P````$``'""`````````)1@``!``@``
-M`0`````````$`````````#\````)``````````````!<JP``6`(```\````'
-M````!`````@```!.`````0````(`````````U&(``$@"``````````````0`
-M````````5@````$````R`````````!QE``#(`P`````````````$`````0``
-M`&4````!``````````````#D:```$@```````````````0````````!N````
-M`0``````````````]F@```````````````````$`````````?@````,``'``
-M`````````/9H```K```````````````!`````````!$````#````````````
-M```A:0``C@```````````````0`````````!`````@``````````````6&P`
-M`,`6```0````_`````0````0````"0````,``````````````!B#``!Q#0``
-M```````````!```````````````````````````````!```````````````$
-M`/'_`````````````````P`!``````````````````,``P``````````````
-M```#``4`#P````````!``````@`!`!D``````````````````0``````````
-M```````#``8``````````````````P`'`!P```!`````P`````(``0`9````
-M0`````````````$`+@`````!```(`````@`!`!D``````0```````````0`^
-M````"`$``%`````"``$`&0````@!```````````!`$X```!8`0``4`````(`
-M`0`9````6`$```````````$`&0```*@!```````````!`%X```#L`0``'```
-M``(``0`9````[`$```````````$`;0````@"``!4`````@`!`!D````(`@``
-M`````````0!]````7`(``!P````"``$`&0```%P"```````````!`(T```!X
-M`@``'`````(``0`9````>`(```````````$`G@```)0"```8`````@`!`!D`
-M``"4`@```````````0"O````K`(``#@````"``$`&0```*P"```````````!
-M`+\```#D`@``"`````(``0`9````Y`(```````````$`T````.P"```(````
-M`@`!`!D```#L`@```````````0#6````]`(```@````"``$`&0```/0"````
-M```````!`/(```#\`@``"`````(``0`9````_`(```````````$`"0$```0#
-M```(`````@`!`!D````$`P```````````0`?`0``#`,```@````"``$`&0``
-M``P#```````````!`"X!```4`P``:`````(``0`9````%`,```````````$`
-M.@$``'P#```(`````@`!`!D```!\`P```````````0!&`0``A`,```@````"
-M``$`&0```(0#```````````!`%(!``",`P``"`````(``0`9````C`,`````
-M``````$`&0```)0#```````````!`!D```"8`P```````````0`9````G`,`
-M``````````$`7P$``"0$```(`````@`!`!D````D!````````````0!H`0``
-M+`0``'P````"``$`&0```"P$```````````!`'\!``"H!```2`````(``0`9
-M````J`0```````````$`C@$````````````````*`),!``#P!```B`8```(`
-M`0`9````\`0```````````$`I`$```@````````````*`*D!```,````````
-M````"@"N`0``*`````````````H`LP$``#@````````````*`+@!``!0````
-M````````"@"^`0``6`````````````H`Q`$``#`````````````*`,D!``!@
-M````````````"@#/`0``:`````````````H`U0$``&P````````````*`-L!
-M``!T````````````"@#A`0``?`````````````H`YP$``)P````````````*
-M`.T!``!@"P```````````0#P`0``>`L``"P!```"``$`&0```'@+````````
-M```!`/X!``"D#```J`,```(``0`9````I`P```````````$`#P(``+0`````
-M```````*`!4"``"\````````````"@#M`0``2!````````````$`&P(``$P0
-M``"T`0```@`!`!D```!,$````````````0`M`@````````````````4`-P(`
-M`-@````````````*`.T!``#\$0```````````0`9`````!(```````````$`
-M/0(``,P2``"@`0```@`!`!D```#,$@```````````0!(`@``Y```````````
-M``H`3@(``.P````````````*`%0"``#T````````````"@!:`@``;!0``!@`
-M```"``$`&0```&P4```````````!`&D"``"$%```6`,```(``0`9````A!0`
-M``````````$`[0$``+@4```````````!`!D```#T%````````````0!V`@``
-MW!<``"@````"``$`&0```-P7```````````!`(X"```$&```J`(```(``0`9
-M````!!@```````````$`G@(``*P:``"``@```@`!`!D```"L&@``````````
-M`0"O`@``+!T``#0````"``$`&0```"P=```````````!`+T"``#X````````
-M````"@##`@``8!T``"@"```"``$`&0```&`=```````````!`-0"``"('P``
-M;`$```(``0`9````B!\```````````$`[0$```@@```````````!`!D````D
-M(````````````0#C`@``]"```#0````"``$`&0```/0@```````````!`/,"
-M`````0``````````"@#Y`@``*"$``%`````"``$`&0```"@A```````````!
-M``H#``!X(0``;`````(``0`9````>"$```````````$`&0,``.0A```P`@``
-M`@`!`!D```#D(0```````````0`H`P``%"0``)0#```"``$`&0```!0D````
-M```````!`#L#```0`0``````````"@#M`0``H"<```````````$`00,``*@G
-M``!(`0```@`!`!D```"H)P```````````0#M`0``#"@```````````$`&0``
-M`!PH```````````!`%0#```4`0``````````"@!:`P``'`$```````````H`
-M8`,``"0!```````````*`&8#``#P*```&`$```(``0`9````\"@`````````
-M``$`[0$``!@I```````````!`!D```!$*0```````````0!V`P``""H``+P#
-M```"``$`&0````@J```````````!`.T!```D*P```````````0`9````9"L`
-M``````````$`[0$````L```````````!`!D```!`+````````````0"%`P``
-M``````````````D`CP,``,0M```8`````@`!`!D```#$+0```````````0"A
-M`P``W"T``*@!```"``$`&0```-PM```````````!`+$#``"$+P``5`$```(`
-M`0`9````A"\```````````$`[0$``-0P```````````!`,$#``#8,```8`$`
-M``(``0`9````V#````````````$`T@,``#@R``"$`0```@`!`!D````X,@``
-M`````````0#B`P``+`$```````````H`Z`,``#P!```````````*`.X#``!,
-M`0``````````"@#T`P``7`$```````````H`^@,``&P!```````````*```$
-M``!\`0``````````"@`&!```C`$```````````H`#`0``)P!```````````*
-M`!($``"L`0``````````"@`8!```O#,``$`!```"``$`&0```+PS````````
-M```!`"D$`````````````````P`S!```_#0``'0````"``$`&0```/PT````
-M```````!`$,$``!P-0``S`L```(``0`9````<#4```````````$`4@0``+P!
-M```````````*`%@$``#0`0``````````"@!>!```S`$```````````H`9`0`
-M`-0!```````````*`&H$``#<`0``````````"@!P!```Y`$```````````H`
-M=@0``.P!```````````*`'P$```\00``+`$```(``0`9````/$$`````````
-M``$`C`0``&A"``!D`````@`!`!D```!H0@```````````0"<!```S$(``"`!
-M```"``$`&0```,Q"```````````!`.T!``#@0P```````````0`9````[$,`
-M``````````$`&0```$1$```````````!`!D```"<1````````````0"K!```
-MW$0``$@"```"``$`&0```-Q$```````````!`.T!```<1P```````````0"[
-M!```)$<``"@&```"``$`&0```"1'```````````!`.T!``#\2```````````
-M`0`9````($D```````````$`RP0``#P"```````````*`-$$``"(`@``````
-M````"@#7!```D`(```````````H`W00``)0"```````````*`.,$``"X`@``
-M````````"@#I!```P`(```````````H`[P0``-`"```````````*`/4$``#@
-M`@``````````"@#[!```"`,```````````H``04``!`#```````````*``<%
-M```4`P``````````"@`-!0``&`,```````````H`$P4``!P#```````````*
-M`!D%```P`P``````````"@#M`0``/$T```````````$`'P4``$Q-``"H````
-M`@`!`!D```!,30```````````0#M`0``C$T```````````$`&0```)Q-````
-M```````!`"\%``#T30``X`````(``0`9````]$T```````````$`/04``-1.
-M```P`````@`!`!D```#43@```````````0`9````!$\```````````$`[0$`
-M`-A/```````````!`!D```#H3P```````````0#M`0``3%(```````````$`
-M&0```)A2```````````!`.T!```(7@```````````0`9````'%X`````````
-M``$`[0$``%A>```````````!`!D```!<7@```````````0!)!0``8`,`````
-M``````H``````````````````P`)`$\%````````!`````$`"0#M`0``````
-M``````````D`6P4```0````-`````0`)`&<%```4````#P````$`"0!V!0``
-M-`````0````!``D`@@4``#@````%`````0`)`(T%``!`````"0````$`"0"8
-M!0``3`````0````!``D`I`4``%````#X`0```0`)`.T!````````````````
-M`P"U!0``;````.`````!``,`P@4``$P!``!P`````0`#````````````````
-M``,`"@#M`0````````````````4`U@4````````0`````0`%`.<%```0````
-M`0````$`!0#\!0``$0````$````!``4`#P8``!@```!(`````0`%````````
-M``````````,`#``````````````````#``L``````````````````P`-`"0&
-M`````````````!`````[!@``J`$``$0````2``$`6`8`````````````$```
-M`%\&``"4`P``!````!(``0!L!@``F`,```0````2``$`>`8``)P#``"(````
-M$@`!`(0&`````````````!````",!@`````````````0````F`8`````````
-M````$````*D&`````````````!````"S!@`````````````0````N@8`````
-M````````$````,$&`````````````!````#4!@`````````````0````VP8`
-M````````````$````.H&`````````````!`````#!P`````````````0````
-M%`<`````````````$````"D'`````````````!`````Z!P`````````````0
-M````2`<`````````````$````%P'`````````````!````!C!P``````````
-M```0````>@<`````````````$````($'`````````````!````")!P``````
-M```````0````FP<`````````````$````*<'`````````````!````"W!P``
-M```````````0````S@<`````````````$````.`'````$@``S````!(``0#Q
-M!P`````````````0````^0<`````````````$`````,(`````````````!``
-M```1"``````````````0````)P@`````````````$````"X(````````````
-M`!`````["``````````````0````1P@`````````````$````%0(````````
-M`````!````!D"``````````````0````=0@`````````````$````(T(````
-M`````````!````"="``````````````0````L`@`````````````$````+X(
-M`````````````!````#-"``````````````0````W0@`````````````$```
-M`.P(`````````````!````#X"``````````````0`````PD`````````````
-M$`````\)`````````````!`````;"0`````````````0````)@D`````````
-M````$````#()`````````````!````!)"0`````````````0````50D`````
-M````````$````&<)`````````````!````!\"0`````````````0````C0D`
-M````````````$````*4)`````````````!````"^"0`````````````0````
-MRPD`````````````$````-P)`````````````!````#N"0`````````````0
-M````^0D`````````````$`````T*`````````````!`````P"@``````````
-M```0````4PH`````````````$````&<*`````````````!````"$"@``````
-M```````0````C0H`````````````$````*8*`````````````!````"R"@``
-M```````````0````N0H`````````````$````,L*`````````````!````#F
-M"@`````````````0````]0H`````````````$`````,+`````````````!``
-M```?"P`````````````0````-`L``.Q#``!8````$@`!`%,+````````````
-M`!````!G"P``1$0``%@````2``$`@PL``)Q$``!`````$@`!`*,+````````
-M`````!````"V"P`````````````0````U0L`````````````$````.(+````
-M`````````!````#N"P`````````````0````]@L`````````````$``````,
-M`````````````!`````-#``````````````0````%`P`````````````$```
-M`"`,`````````````!`````R#``````````````0````1`P`````````````
-M$````%<,`````````````!````!G#```!$\``!@/```2``$`<0P`````````
-M````$````(4,`````````````!````"3#``````````````0````J@P`````
-M````````$````+8,`````````````!````#,#``````````````0````V@P`
-M`!Q>``!`````$@`!`/(,`````````````!`````$#0``7%X``#@````2``$`
-M'`T`````````````$````"L-````````,````!$``P`U#0``,````"0````1
-M``,`2@T``!0````$````$0`%`&`-``!4````&````!$``P``:6]C=&Q?;&EN
-M=7@N8P!H97@R;G5M7VD`)&$`=W!A7W-E=%]A=71H7V%L9W,`<G1W7W=X7W-E
-M=%]F<F5Q`')T=U]W>%]G971?;6]D90!R='=?=WA?9V5T7W-E;G,`<G1W7W=X
-M7V=E=%]R=',`<G1W7W=X7W-E=%]F<F%G`')T=U]W>%]G971?9G)A9P!R='=?
-M=WA?9V5T7W)E=')Y`')T=U]W>%]G971?<&]W97(`<G1W7W=X7W=R:71E7W)F
-M`')T=U]W>%]P<FEV7VYU;&P`9'5M;7D`<G1W7W=X7W-E=%]M=&M?=W!S7W!R
-M;V)E7VEE`')T=U]W>%]G971?<V5N<VET:79I='D`<G1W7W=X7W-E=%]M=&M?
-M=W!S7VEE`')T=U]D<G9E>'1?:&1L`')T=U]S971?<&ED`')T=U]P,G!?<V5T
-M`')T=U]P,G!?9V5T`')T=U]P,G!?9V5T,@!R='=?=&1L<P!R='=?9V5T7W=I
-M<F5L97-S7W-T871S`')T=U]W>%]R96%D7W)F`"Y,0S``<G1W7VUP7V5F=7-E
-M7V=E=``N3$,Q`"Y,0S(`+DQ#-0`N3$,X`"Y,0S$Q`"Y,0S$R`"Y,0S8`+DQ#
-M,3,`+DQ#,30`+DQ#,34`+DQ#,38`+DQ#,3<`+DQ#,3@`)&0`<G1W7W=P<U]S
-M=&%R=`!R='=?;7!?969U<V5?<V5T`"Y,0S$Y`"Y,0S(P`')T=U]R97)E9U]N
-M9%]N86UE`"Y,04Y#2$]2,``N3$,R,@!R='=?<&U?<V5T`"Y,0S(S`"Y,0S(T
-M`"Y,0S(U`')T=U]W>%]W<FET93,R`')T=U]D8F=?<&]R=`!R='=?=WA?<V5T
-M7V-H86YN96Q?<&QA;@!R='=?9V5T7V%P7VEN9F\`<G1W7VUP7VEO8W1L7VAD
-M;`!R='=?=WA?<F5A9#,R`"Y,0S(V`')T=U]W>%]S971?<&UK:60`<G1W7W=X
-M7V=E=%]E;F,`<G1W7W=X7V=E=%]N:6-K`"Y,0S(W`')T=U]W>%]G971?97-S
-M:60`<G1W7W=X7V=E=%]W87``<G1W7W=X7W-E=%]E;F,`=W!A7W-E=%]E;F-R
-M>7!T:6]N`"Y,0S(X`')T=U]W>%]S971?96YC7V5X=``N3$,R.0`N3$,S,``N
-M3$,S,0!R='=?=WA?<V5T7V%U=&@`<G1W7W-E=%]W<&%?:64`+DQ!3D-(3U(Q
-M`')T=U]W>%]S971?9V5N7VEE`')T=U]W>%]G971?<F%T90!R='=?=WA?<V5T
-M7W)A=&4`<G1W7W=X7W-E=%]E<W-I9`!R='=?=WA?9V5T7VYA;64`+DQ#,S(`
-M+DQ#,S,`+DQ#,S0`+DQ#,S4`+DQ#,S8`+DQ#,S<`+DQ#,S@`+DQ#,SD`+DQ#
-M-#``<G1W7W=X7V=E=%]R86YG90`N3$%.0TA/4C(`<G1W7W=X7V=E=%]F<F5Q
-M`'1R86YS;&%T95]S8V%N`"Y,0S0Q`"Y,0S0S`"Y,0S0R`"Y,0S0T`"Y,0S0U
-M`"Y,0S0V`"Y,0S0W`')T=U]W>%]G971?<V-A;@!R='=?=WA?<V5T7VUL;64`
-M<G1W7W=X7W-E=%]W87``<G1W7W=X7W-E=%]S8V%N`')T=U]W>%]S971?<')I
-M=@`N3$,U,@`N3$,U-``N3$,U-0`N3$,U-@`N3$,U-P`N3$,U.``N3$,U.0`N
-M3$,V,``N3$,V,0`N3$,V,@`N3$,V,P`N3$,V-``N3$,V-0`N3$,V-@!R='=?
-M=WA?<V5T7VUO9&4`<V5T7V=R;W5P7VME>0!S971?=V5P7VME>0`N3$,V-P!#
-M+C4R-"XS-C@P-@!#+C4U,2XS-S4S,@!?7V9U;F-?7RXS-S$P-@!#+C8U-BXS
-M.3,Y-0!#4U=40T@N-C@Y`$-35U1#2"XV.3(`0RXV,S@N,SDQ-C@`<G1W7W!R
-M:79A=&5?87)G<P!R='=?:&%N9&QE<G,`<G1W7W!R:79A=&5?:&%N9&QE<@!O
-M;&1?:69N86UE+C,X,S4X`&]L9%]B4F5G57-E3&5D+C,X,S8P`&]L9%]I<'-?
-M;6]D92XS.#,U.0!R=&PX,3@X7W-U<W!E;F1?;&]C:P!?7V%E86)I7W5N=VEN
-M9%]C<'!?<'(P`')T=U]I<U]F:71?<F5G=6QA=&]R>5]D;VUA:6X`=6E?<&ED
-M`&UA8U]R96=?9'5M<`!B8E]R96=?9'5M<`!R9E]R96=?9'5M<`!S<')I;G1F
-M`%]R='=?;65M<V5T`%]?8V]P>5]F<F]M7W5S97(`7U]M96UZ97)O`'-T<G-E
-M<`!S=')C;7``<G1W7V5F=7-E7VUA<%]R96%D`'-T<FQE;@!S:6UP;&5?<W1R
-M=&]U;`!%1E5315]'971%9G5S941E9FEN:71I;VX`<G1W7V5F=7-E7V%C8V5S
-M<P!E9G5S95]'971#=7)R96YT4VEZ90!E9G5S95]'971-87A3:7IE`&ME>5\R
-M8VAA<C)N=6T`<G1W7V5F=7-E7VUA<%]W<FET90!P<FEN=&L`7U]A96%B:5]U
-M;G=I;F1?8W!P7W!R,0!I9FYA;64`<W1R;F-P>0!R='=?8VAA;F=E7VEF;F%M
-M90!?<G1W7VUE;6-M<`!R='=?<W=?;&5D7VEN:70`<G1W7V9R965?;F5T=V]R
-M:U]Q=65U90!R='=?<W=?;&5D7V1E:6YI=`!R9G!W<G-T871E7V-H96-K`&II
-M9F9I97,`;6]D7W1I;65R`'-T<E\R8VAA<C)N=6T`3&5A=F5!;&Q0;W=E<E-A
-M=F5-;V1E`'-S8V%N9@!?<G1W7W=R:71E,S(`7W)T=U]W<FET93@`7W)T=U]W
-M<FET93$V`')T=U]G971?<W1A:6YF;P!L;V-A;%]B:%]D:7-A8FQE`')T=U]E
-M;F1?;V9?<75E=65?<V5A<F-H`&QO8V%L7V)H7V5N86)L90!R='=?<V5T7V-H
-M<&QA;E]C;60`<G1W7VUS;&5E<%]O<P!R='=?9V5T7W=P85]I90!R='=?9V5T
-M7W=P83)?:64`7U]C;W!Y7W1O7W5S97(`7W)T=U]M86QL;V,`7W)T=U]R96%D
-M.`!?<G1W7W)E860Q-@!?<G1W7W)E860S,@!?<G1W7VUF<F5E`%]R='=?;65M
-M8W!Y`')T=U]S971?.#`R7S$Q7V%D9%]W97``<G1W7W-E=%]K97D`<G1W7W-E
-M='-T86ME>5]C;60`<G1W7V=E=%]B8VUC7W-T86EN9F\`<G1W7V1I<V%S<V]C
-M7V-M9`!R='=?:6YD:6-A=&5?9&ES8V]N;F5C=`!R='=?9G)E95]A<W-O8U]R
-M97-O=7)C97,`7W)T=U]Z;6%L;&]C`')T=U]P87)S95]W<&%?:64`<G1W7W!A
-M<G-E7W=P83)?:64`<G1W7V=E=%]I90!R='=?<V5T9&%T87)A=&5?8VUD`')T
-M=U]S971?.#`R7S$Q7VEN9G)A<W1R=6-T=7)E7VUO9&4`<G1W7W-E=%\X,#)?
-M,3%?875T:&5N=&EC871I;VY?;6]D90!R='=?<V5T7S@P,E\Q,5]S<VED`')T
-M=U]I<U]C8VMR871E<V]N;'E?:6YC;'5D960`<VYP<FEN=&8`<G1W7VES7V-C
-M:W)A=&5S7VEN8VQU9&5D`')T=U]C:#)F<F5Q`&UE;6-P>0!R='=?=F%L:61A
-M=&5?<W-I9`!R='=?9V5T7V-A<&%B:6QI='E?9G)O;5]I90!R='=?9V5T7W-E
-M8U]I90!R='=?:7-?=W!S7VEE`')T=U]S971?.#`R7S$Q7V1I<V%S<V]C:6%T
-M90!R='=?<V5T7S@P,E\Q,5]B<W-I9`!R='=?:6YD:6-A=&5?=WA?9&ES87-S
-M;V-?979E;G0`=VER96QE<W-?<V5N9%]E=F5N=`!R='=?:6YD:6-A=&5?=WA?
-M87-S;V-?979E;G0`:6YD:6-A=&5?=WA?<V-A;E]C;VUP;&5T95]E=F5N=`!R
-M='=?<VET97-U<G9E>5]C;60`<G1W7W-E=%\X,#)?,3%?8G-S:61?;&ES=%]S
-M8V%N`%]R='=?=FUA;&QO8P!?<G1W7W9M9G)E90!S=')N8VUP`'=A:V5?;&]C
-M:P!S;&5E<%]R97-U;64`;7-L965P`'=A:V5?=6YL;V-K`&EN:71?8VAA;FYE
-M;%]P;&%N`')T=U]S971O<&UO9&5?8VUD`%]R='=?:6YI=%]L:7-T:&5A9`!R
-M='=?96YQ=65U95]C;60`<G1W7VEO8W1L`&9L=7-H7V%L;%]C86U?96YT<GD`
-M<G1W7W-T85]F;'5S:`!U<&1A=&5?<W1A7VEN9F]?87!M;V1E`&%P7V9R965?
-M<W1A`')T=U]C:&5C:U]B96%C;VY?9&%T80!U<&1A=&5?8F5A8V]N`')T;#@Q
-M.#A?<&]W97)?<V%V95]E>&ET`'=A:V5?;&]C:U]D97-T<F]Y`')T;#@Q.#A?
-M<&]W97)?<V%V95]I;FET`'=A:V5?;&]C:U]I;FET`')T=U]R871E<P!A;F1R
-M;VED7W=I9FE?8VUD7W-T<@!R=&PX,3@X7W=A:V5L;V-K7VEN:70`<G1W7VAA
-M;F1L97)S7V1E9@````!<`P``*_X``&`#```L_@``V`0``"L[``#<!```+#L`
-M`.0$```<`@$`,`4``!P#`0!`!0``'`,!`'@%```<!`$`F`4``!P%`0"\!0``
-M*SX``,`%```L/@``Z`4``!P&`0#\!0``*S\````&```L/P``!`8``!P'`0`@
-M!@``'`@!`#@&```<`P$`2`8``!P"`0!4!@``*T```%@&```L0```;`8``!P"
-M`0"0!@``'`(!`*P&```<`@$`P`8``!P"`0#@!@``'`(!`/0&```<"0$`"`<`
-M`"M!```,!P``+$$``!`'```<!P$`0`<``!P*`0!4!P``'`H!`(@'```<"P$`
-MM`<``!P(`0#$!P``'`,!`.P'```<`@$`_`<``!P"`0`0"```'`D!`"@(```K
-M0@``+`@``"Q"```P"```'`<!`%0(```<#`$`;`@``!P#`0!T"```*T,``'@(
-M```L0P``@`@``"M$``"$"```+$0``(@(```K10``C`@``"Q%``"@"```'`(!
-M`+P(```<`@$`W`@``!P"`0#P"```'`D!``0)```K1@``"`D``"Q&```,"0``
-M'`<!`%`)```<"P$`=`D``!P(`0"$"0``'`,!`*@)```<`@$`N`D``!P"`0#,
-M"0``'`D!`.`)```K1P``Y`D``"Q'``#H"0``'`<!`"P*```<"P$`4`H``!P(
-M`0!@"@``'`,!`(0*```<`@$`E`H``!P"`0"H"@``'`D!`+P*```K2```P`H`
-M`"Q(``#$"@``'`<!`.0*```<#0$`[`H``!P.`0``"P``*TD```0+```L20``
-M#`L``!P"`0`4"P``'`D!`"@+```K2@``+`L``"Q*```T"P``'`(!`#P+```<
-M"0$`8`L```+S``!D"P```O,``&@+```"\P``;`L```+S``!P"P```O,``'0+
-M```"\P``Q`L``!P$`0#4"P``'`4!`-@,```K/@``W`P``"P^````#0``'`8!
-M`!0-```K4```&`T``"Q0```<#0``'`<!`$@-```<"@$`5`T``!P)`0!T#0``
-M'`\!`+`-```<"P$`V`T``!P0`0#L#0``*U$``/`-```L40``]`T``!P'`0`@
-M#@``'`H!`"P.```<"0$`3`X``!P/`0!\#@``'`P!`)`.```K1@``E`X``"Q&
-M``"8#@``'`<!`,`.```<"0$`Z`X``!P/`0`@#P``'`L!`$@/```<$`$`7`\`
-M`"M'``!@#P``+$<``&0/```<!P$`C`\``!P)`0"L#P``'`\!`.0/```<"P$`
-M#!```!P0`0`@$```'!$!`$@0```"\P``7!```"M5``!@$```+%4``'00```K
-M$P$`>!```"P3`0"($```'!0!`-`0```<!`$`Z!```!P%`0#\$```'!4!``@1
-M```K50``#!$``"Q5```0$0``*U8``!01```L5@``'!$``!P6`0`\$0``'!<!
-M`$P1```K50``4!$``"Q5``!D$0``'!0!`'01```K5@``>!$``"Q6``"`$0``
-M'!8!`)01```<&`$`M!$``"M5``"X$0``+%4``-01```<&0$`_!$```($``!X
-M$@``*QL!`'P2```L&P$`K!(``!P<`0#D$@``*UL``.@2```L6P``\!(``!P6
-M`0!($P``'!T!`(`3```<'@$`H!,``"M<``"D$P``+%P``*P3```<%@$`V!,`
-M`"M=``#<$P``+%T``.`3```<'P$`!!0``"L;`0`(%```+!L!`#@4```<'`$`
-M3!0``!P:`0!X%```'"`!`+@4```"`@``O!0```("``#`%````@(``,04```"
-M`@``R!0```("``#,%````@(``-`4```"`@``U!0```("``#8%````@(``-P4
-M```"`@``X!0```("``#D%````@(``.@4```"`@``[!0```("``#P%````@(`
-M`!@5```<(0$`+!4``!PB`0!`%0``'"`!`"@6```<(P$`<!8``!PD`0"T%@``
-M'"4!`.@6```<)@$`)!<``!S_```X%P``'``!`$P7```<`0$`O!<``!PA`0#,
-M%P``'"$!`/`7```<)P$`2!@``!PH`0"H&```'`0!`,`8```<!0$`S!@``!PD
-M`0`(&0``'"4!`(@9```<)@$`J!D``!PI`0#<&0``'"H!`"0:```<)@$`:!H`
-M`!PK`0"<&@``'!8!`.`:```<+`$`(!L``!P$`0!`&P``'`4!`+P;```<+0$`
-MT!L``!PN`0#D&P``'"\!`!@<```<(0$`+!P``!PB`0!`'```'"`!`.P<```<
-M*P$`)!T``!PP`0`\'0``'"\!`$@=```K;```3!T``"QL``!4'0``'`(!`)`=
-M```<,0$`K!T``!P6`0#@'0``'!8!``0>```<,0$`?!X``!P6`0"@'@``'`,!
-M`.@>```<`P$`-!\``!PQ`0!0'P``'#$!``@@```"`@``#"````("```0(```
-M`@(``!0@```"`@``&"````("```<(````@(``"`@```"`@``="```!PQ`0`0
-M(0``*W4``!0A```L=0``'"$``!PQ`0!@(0``'#$!`)@A```<`P$`Q"$``!PQ
-M`0#8(0``'`,!``0B```<`P$`V",``!PQ`0#D(P``'#(!`'0D```K?@``>"0`
-M`"Q^``!\)```'`<!`-@D```<+`$`\"0``!P#`0`L)0``'#$!`$0E```<,@$`
-M="4``!PQ`0"<)0``'#,!`-PE```<(P$`\"4``!P'`0!`)@``'#$!`$PF```<
-M!P$`9"8``!PQ`0!T)@``'#$!`)`F```<-`$`O"8``!PQ`0#8)@``'#$!`/0F
-M```<,0$`'"<``!PS`0`D)P``'#4!`#@G```<!P$`F"<``!PP`0"@)P```O,`
-M`*0G```"\P``Q"<``!PL`0#@)P``'`,!`/@G```<`P$`#"@```("```0*```
-M`@(``!0H```"`@``&"@```("```<*```*WX``"`H```L?@``*"@``"N$```L
-M*```+(0``#0H```KA0``."@``"R%``!`*```*X8``$0H```LA@``5"@``!P4
-M`0"<*```'#$!`+PH```<,0$`W"@``!PP`0`8*0```@(``!PI```"`@``("D`
-M``("```D*0```@(``"@I```"`@``+"D```("```P*0```@(``#0I```"`@``
-M."D```("```\*0```@(``$`I```"`@``U"D``!PV`0#<*0``'#<!`.0I```<
-M.`$`>"H``!PY`0"4*@``'#$!`+@J```<.@$`["H``!P[`0`D*P```@(``"@K
-M```"`@``+"L```("```P*P```@(``#0K```"`@``."L```("```\*P```@(`
+M```HL@&!L+!?A```````````L+"P@$````"PL*"```$``+"PL(`(`0``L+"P
+M@%@!``"PL*"`J`$``+"PL(#L`0``L+"P@`@"``"PL*"`7`(``+"PL(!X`@``
+ML+"P@)0"``"PL+"`K`(``+"H`8#D`@``L+"P@.P"``"PL+"`]`(``+"PL(#\
+M`@``L+"P@`0#``"PL+"`#`,``+"PL(`4`P``L+"B@'P#``"PL+"`A`,``+"P
+ML(",`P``L+"P@)0#``"PL+"`F`,``+"PL("<`P``L*X!@"0$``"PL+"`+`0`
+M`+"PH("L!```L+"J@/0$``"O*+*`?`L``+"L`8"H#````````%`0``"PJP2`
+M'!(``+"PJ(#H$@``L*P!@(@4``"PL*B`H!0``+"L`X#\%P``L+"H@"08``"P
+MKPZ`S!H``+"N`8!,'0``L+"J@(`=``"PK@.`J!\``+"PJH`,(0``L+"H@$`A
+M``"PL*J`D"$``+"PJH#\(0``L*P'@"@D``"PL*Z`P"<``+"PKH`(*0``L+"J
+M@"`J``"PKP2`W"T``+"PJ(#T+0``7X0"@)PO``"PJ@>`\#```%^$"H!0,@``
+ML*L"@-0S``"O"+&`%#4``+"PJH"(-0``KT2R@%1!``"PKP:`@$(``+"PJH#D
+M0@``L+"N@`1$``"PJ02`7$0``+"I!("T1```L*D$@/1$``"PKPJ`/$<``*\_
+M&(!D30``L+"J@`Q.``"PL*Z`\$X``+"PJ(`@3P``L*\$@$A>``"PL*B`B%X`
+M`+"PJH``4/($"PH)"`<&!00#`@$`_P```')T=U]W>%]S971?=V%P``!#4T-!
+M3B!3`0``4P```````%#R!`40$!`-`````0`````````%`````%#R!."+```"
+M2```<G1W7W=R:71E,S(``````.&+```!2!`H<G1W7W)E860S,@```````.*+
+M````````9')I=F5R7V5X=````````..+````````````````````````````
+M`.2+```!2```87!I;F9O`````````````.6+```"2```<V5T<&ED````````
+M`````.:+```!2```=W!S7W-T87)T`````````.>+```!2```9V5T7W-E;G-I
+M=&EV:71Y`.B+```!2```=W!S7W!R;V)?<F5Q7VEE`.F+```!2```=W!S7V%S
+M<V]C7W)E<5]I9>J+```!2```8VAA;FYE;%]P;&%N`````.N+```"2```9&)G
+M`````````````````.R+```#2```<F9W`````````````````.V+```"2!`H
+M<F9R`````````````````/"+``!`(```<#)P7W-E=````````````/&+``!`
+M($`H<#)P7V=E=````````````/*+``!`(!`@<#)P7V=E=#(``````````/:+
+M``!`(```<&U?<V5T`````````````/B+```0(```<F5R96=?;F1?;F%M90``
+M`/J+``"`(```969U<V5?<V5T`````````/N+``"`(``O969U<V5?9V5T````
+M`````#!X)3`U>```+````')E86QM87``)7,@"@`````E<R`),'@E,#)X"0`E
+M<R`E,#)8`"5S"0`E<PH`<FUA<``````E<R`P>"4P,E@````E<R``<F5A;')A
+M=P`E<R`E,#)X`"5S"@D`````;6%C`'9I9'!I9```86)L97)A=P`E<R`Z(%L@
+M879A:6QA8FQE(')A=R!S:7IE72`]("5D`"5S(#H@0V]M;6%N9"!N;W0@9F]U
+M;F0*`'=M87``````=W)A=P````!#;VUM86YD(&YO="!F;W5N9`H``&1I<V%B
+M;&4E9````&QP<ST`````:7!S/0`````E=0``,'@E,#AX```\5TE&24!214%,
+M5$5+/@``5T50`&YO;F4`````5$M)4`````!#0TU0`````$E%144@.#`R+C$Q
+M8FX```!)145%(#@P,BXQ,6(`````245%12`X,#(N,3%B9VX``$E%144@.#`R
+M+C$Q8F<```!)145%(#@P,BXQ,6%N````245%12`X,#(N,3%A`````$E%144@
+M.#`R+C$Q9VX```!)145%(#@P,BXQ,6<`````=6YA<W-O8VEA=&5D`````"!2
+M871E<R`H36(O<RDZ(```````+C4``"5D)7,@````=W!A7VEE/0`E,#)X````
+M`')S;E]I93T`)7,Z(')F<'=R<W1A=&5?8VAE8VL@9F%I;"X*`"5S.B!T96UP
+M+3YS85]F86UI;'D@(3T@05)02%)$7T542$52+@H````E8P``04Y$4D])1%]7
+M249)7T--1%]35$%25"XN+BXN+BXN+BX*````=V%I=&EN9R!F;W(@=VEF:2!D
+M<FEV97(@=&\@8F4@<F5A9'DN+BX*`%-405)4````3TL``$%.1%)/241?5TE&
+M25]#341?4U1/4"XN+BXN+BXN+BX*`````%-43U``````5TE&22!R<W-I("5D
+M`````$Q)3DM34$5%1"`E9`````!-04-!1$12(#T@)3`R>#HE,#)X.B4P,G@Z
+M)3`R>#HE,#)X.B4P,G@`)2IS("5S``!54P``154``$I0``!38V%N+4-H86YN
+M96QS(#T@)60``$=E="!#:&%N;F5L<R!R971U<FX@)60@*&EN:71?8VAA;FYE
+M;%]P;&%N/25D*0H``')T;#@Q.#A?=VEF:5]W86ME;&]C:P```%)34TD`````
+M3$E.2U-0145$````34%#041$4@!30T%.+4%#5$E610!30T%.+5!!4U-)5D4`
+M````0T]53E1260!30T%.+4-(04Y.14Q3`````$=#0SH@*$=.52D@-"XT+C``
+M02H```!A96%B:0`!(`````4W+4$`!@H'00@!$@04`14!%P,8`1D!&@(>`0`N
+M<WEM=&%B`"YS=')T86(`+G-H<W1R=&%B`"YR96PN=&5X=``N<F5L+F1A=&$`
+M+F)S<P`N05)-+F5X=&%B`"YR96PN05)-+F5X:61X`"YR;V1A=&$`+G)O9&%T
+M82YS='(Q+C0`+F-O;6UE;G0`+FYO=&4N1TY5+7-T86-K`"Y!4DTN871T<FEB
+M=71E<P``````````````````````````````````````````````````````
+M`!\````!````!@`````````T````P%X`````````````!``````````;````
+M"0``````````````M)```%`8```/`````0````0````(````*0````$````#
+M`````````/1>``"\`0`````````````$`````````"4````)````````````
+M```$J0``B`(```\````#````!`````@````O````"`````,`````````L&``
+M`&````````````````@`````````-`````$````"`````````+!@```,````
+M```````````$`````````$,````!``!P@@````````"\8```0`(```$`````
+M````!``````````_````"0``````````````C*L``%@"```/````!P````0`
+M```(````3@````$````"`````````/QB``!(`@`````````````$````````
+M`%8````!````,@````````!$90``R`,`````````````!`````$```!E````
+M`0``````````````#&D``!(```````````````$`````````;@````$`````
+M`````````!YI```````````````````!`````````'X````#``!P````````
+M```>:0``*P```````````````0`````````1`````P``````````````26D`
+M`(X```````````````$``````````0````(``````````````(!L``#`%@``
+M$````/P````$````$`````D````#``````````````!`@P``<0T`````````
+M`````0```````````````````````````````0``````````````!`#Q_P``
+M``````````````,``0`````````````````#``,``````````````````P`%
+M``\`````````0`````(``0`9``````````````````$`````````````````
+M`P`&``````````````````,`!P`<````0````,`````"``$`&0```$``````
+M```````!`"X``````0``"`````(``0`9``````$```````````$`/@````@!
+M``!0`````@`!`!D````(`0```````````0!.````6`$``%`````"``$`&0``
+M`%@!```````````!`!D```"H`0```````````0!>````[`$``!P````"``$`
+M&0```.P!```````````!`&T````(`@``5`````(``0`9````"`(`````````
+M``$`?0```%P"```<`````@`!`!D```!<`@```````````0"-````>`(``!P`
+M```"``$`&0```'@"```````````!`)X```"4`@``&`````(``0`9````E`(`
+M``````````$`KP```*P"```X`````@`!`!D```"L`@```````````0"_````
+MY`(```@````"``$`&0```.0"```````````!`-````#L`@``"`````(``0`9
+M````[`(```````````$`U@```/0"```(`````@`!`!D```#T`@``````````
+M`0#R````_`(```@````"``$`&0```/P"```````````!``D!```$`P``"```
+M``(``0`9````!`,```````````$`'P$```P#```(`````@`!`!D````,`P``
+M`````````0`N`0``%`,``&@````"``$`&0```!0#```````````!`#H!``!\
+M`P``"`````(``0`9````?`,```````````$`1@$``(0#```(`````@`!`!D`
+M``"$`P```````````0!2`0``C`,```@````"``$`&0```(P#```````````!
+M`!D```"4`P```````````0`9````F`,```````````$`&0```)P#````````
+M```!`%\!```D!```"`````(``0`9````)`0```````````$`:`$``"P$``"`
+M`````@`!`!D````L!````````````0!_`0``K`0``$@````"``$`&0```*P$
+M```````````!`(X!````````````````"@"3`0``]`0``(@&```"``$`&0``
+M`/0$```````````!`*0!```(````````````"@"I`0``#`````````````H`
+MK@$``"@````````````*`+,!```X````````````"@"X`0``4```````````
+M``H`O@$``%@````````````*`,0!```P````````````"@#)`0``8```````
+M``````H`SP$``&@````````````*`-4!``!L````````````"@#;`0``=```
+M``````````H`X0$``'P````````````*`.<!``"<````````````"@#M`0``
+M9`L```````````$`\`$``'P+```L`0```@`!`!D```!\"P```````````0#^
+M`0``J`P``*@#```"``$`&0```*@,```````````!``\"``"T````````````
+M"@`5`@``O`````````````H`[0$``$P0```````````!`!L"``!0$```S`$`
+M``(``0`9````4!````````````$`+0(````````````````%`#<"``#8````
+M````````"@#M`0``&!(```````````$`&0```!P2```````````!`#T"``#H
+M$@``H`$```(``0`9````Z!(```````````$`2`(``.0````````````*`$X"
+M``#L````````````"@!4`@``]`````````````H`6@(``(@4```8`````@`!
+M`!D```"(%````````````0!I`@``H!0``%P#```"``$`&0```*`4````````
+M```!`.T!``#4%````````````0`9````$!4```````````$`=@(``/P7```H
+M`````@`!`!D```#\%P```````````0".`@``)!@``*@"```"``$`&0```"08
+M```````````!`)X"``#,&@``@`(```(``0`9````S!H```````````$`KP(`
+M`$P=```T`````@`!`!D```!,'0```````````0"]`@``^`````````````H`
+MPP(``(`=```H`@```@`!`!D```"`'0```````````0#4`@``J!\``&0!```"
+M``$`&0```*@?```````````!`.T!```H(````````````0`9````1"``````
+M``````$`XP(```PA```T`````@`!`!D````,(0```````````0#S`@````$`
+M``````````H`^0(``$`A``!0`````@`!`!D```!`(0```````````0`*`P``
+MD"$``&P````"``$`&0```)`A```````````!`!D#``#\(0``+`(```(``0`9
+M````_"$```````````$`*`,``"@D``"8`P```@`!`!D````H)```````````
+M`0`[`P``$`$```````````H`[0$``+@G```````````!`$$#``#`)P``2`$`
+M``(``0`9````P"<```````````$`[0$``"0H```````````!`!D````T*```
+M`````````0!4`P``%`$```````````H`6@,``!P!```````````*`&`#```D
+M`0``````````"@!F`P``""D``!@!```"``$`&0````@I```````````!`.T!
+M```P*0```````````0`9````7"D```````````$`=@,``"`J``"\`P```@`!
+M`!D````@*@```````````0#M`0``/"L```````````$`&0```'PK````````
+M```!`.T!```8+````````````0`9````6"P```````````$`A0,`````````
+M```````)`(\#``#<+0``&`````(``0`9````W"T```````````$`H0,``/0M
+M``"H`0```@`!`!D```#T+0```````````0"Q`P``G"\``%0!```"``$`&0``
+M`)PO```````````!`.T!``#L,````````````0#!`P``\#```&`!```"``$`
+M&0```/`P```````````!`-(#``!0,@``A`$```(``0`9````4#(`````````
+M``$`X@,``"P!```````````*`.@#```\`0``````````"@#N`P``3`$`````
+M``````H`]`,``%P!```````````*`/H#``!L`0``````````"@``!```?`$`
+M``````````H`!@0``(P!```````````*``P$``"<`0``````````"@`2!```
+MK`$```````````H`&`0``-0S``!``0```@`!`!D```#4,P```````````0`I
+M!`````````````````,`,P0``!0U``!T`````@`!`!D````4-0``````````
+M`0!#!```B#4``,P+```"``$`&0```(@U```````````!`%($``"\`0``````
+M````"@!8!```T`$```````````H`7@0``,P!```````````*`&0$``#4`0``
+M````````"@!J!```W`$```````````H`<`0``.0!```````````*`'8$``#L
+M`0``````````"@!\!```5$$``"P!```"``$`&0```%1!```````````!`(P$
+M``"`0@``9`````(``0`9````@$(```````````$`G`0``.1"```@`0```@`!
+M`!D```#D0@```````````0#M`0``^$,```````````$`&0````1$````````
+M```!`!D```!<1````````````0`9````M$0```````````$`JP0``/1$``!(
+M`@```@`!`!D```#T1````````````0#M`0``-$<```````````$`NP0``#Q'
+M```H!@```@`!`!D````\1P```````````0#M`0``%$D```````````$`&0``
+M`#A)```````````!`,L$```\`@``````````"@#1!```B`(```````````H`
+MUP0``)`"```````````*`-T$``"4`@``````````"@#C!```N`(`````````
+M``H`Z00``,`"```````````*`.\$``#0`@``````````"@#U!```X`(`````
+M``````H`^P0```@#```````````*``$%```0`P``````````"@`'!0``%`,`
+M``````````H`#04``!@#```````````*`!,%```<`P``````````"@`9!0``
+M,`,```````````H`[0$``%1-```````````!`!\%``!D30``J`````(``0`9
+M````9$T```````````$`[0$``*1-```````````!`!D```"T30``````````
+M`0`O!0``#$X``.0````"``$`&0````Q.```````````!`#T%``#P3@``,```
+M``(``0`9````\$X```````````$`&0```"!/```````````!`.T!``#T3P``
+M`````````0`9````!%````````````$`[0$``&A2```````````!`!D```"T
+M4@```````````0#M`0``-%X```````````$`&0```$A>```````````!`.T!
+M``"$7@```````````0`9````B%X```````````$`204``&`#```````````*
+M``````````````````,`"0!/!0````````0````!``D`[0$`````````````
+M```)`%L%```$````#0````$`"0!G!0``%`````\````!``D`=@4``#0````$
+M`````0`)`((%```X````!0````$`"0"-!0``0`````D````!``D`F`4``$P`
+M```$`````0`)`*0%``!0````^`$```$`"0#M`0````````````````,`M04`
+M`&P```#@`````0`#`,(%``!,`0``<`````$``P`````````````````#``H`
+M[0$````````````````%`-8%````````$`````$`!0#G!0``$`````$````!
+M``4`_`4``!$````!`````0`%``\&```8````2`````$`!0``````````````
+M```#``P``````````````````P`+``````````````````,`#0`D!@``````
+M```````0````.P8``*@!``!$````$@`!`%@&`````````````!````!?!@``
+ME`,```0````2``$`;`8``)@#```$````$@`!`'@&``"<`P``B````!(``0"$
+M!@`````````````0````C`8`````````````$````)@&`````````````!``
+M``"I!@`````````````0````LP8`````````````$````+H&````````````
+M`!````#!!@`````````````0````U`8`````````````$````-L&````````
+M`````!````#J!@`````````````0`````P<`````````````$````!0'````
+M`````````!`````I!P`````````````0````.@<`````````````$````$@'
+M`````````````!````!<!P`````````````0````8P<`````````````$```
+M`'H'`````````````!````"!!P`````````````0````B0<`````````````
+M$````)L'`````````````!````"G!P`````````````0````MP<`````````
+M````$````,X'`````````````!````#@!P``'!(``,P````2``$`\0<`````
+M````````$````/D'`````````````!`````#"``````````````0````$0@`
+M````````````$````"<(`````````````!`````N"``````````````0````
+M.P@`````````````$````$<(`````````````!````!4"``````````````0
+M````9`@`````````````$````'4(`````````````!````"-"```````````
+M```0````G0@`````````````$````+`(`````````````!````"^"```````
+M```````0````S0@`````````````$````-T(`````````````!````#L"```
+M```````````0````^`@`````````````$`````,)`````````````!`````/
+M"0`````````````0````&PD`````````````$````"8)`````````````!``
+M```R"0`````````````0````20D`````````````$````%4)````````````
+M`!````!G"0`````````````0````?`D`````````````$````(T)````````
+M`````!````"E"0`````````````0````O@D`````````````$````,L)````
+M`````````!````#<"0`````````````0````[@D`````````````$````/D)
+M`````````````!`````-"@`````````````0````,`H`````````````$```
+M`%,*`````````````!````!G"@`````````````0````A`H`````````````
+M$````(T*`````````````!````"F"@`````````````0````L@H`````````
+M````$````+D*`````````````!````#+"@`````````````0````Y@H`````
+M````````$````/4*`````````````!`````#"P`````````````0````'PL`
+M````````````$````#0+```$1```6````!(``0!3"P`````````````0````
+M9PL``%Q$``!8````$@`!`(,+``"T1```0````!(``0"C"P`````````````0
+M````M@L`````````````$````-4+`````````````!````#B"P``````````
+M```0````[@L`````````````$````/8+`````````````!``````#```````
+M```````0````#0P`````````````$````!0,`````````````!`````@#```
+M```````````0````,@P`````````````$````$0,`````````````!````!7
+M#``````````````0````9PP``"!/```H#P``$@`!`'$,`````````````!``
+M``"%#``````````````0````DPP`````````````$````*H,````````````
+M`!````"V#``````````````0````S`P`````````````$````-H,``!(7@``
+M0````!(``0#R#``````````````0````!`T``(A>```X````$@`!`!P-````
+M`````````!`````K#0```````#`````1``,`-0T``#`````D````$0`#`$H-
+M```4````!````!$`!0!@#0``5````!@````1``,``&EO8W1L7VQI;G5X+F,`
+M:&5X,FYU;5]I`"1A`'=P85]S971?875T:%]A;&=S`')T=U]W>%]S971?9G)E
+M<0!R='=?=WA?9V5T7VUO9&4`<G1W7W=X7V=E=%]S96YS`')T=U]W>%]G971?
+M<G1S`')T=U]W>%]S971?9G)A9P!R='=?=WA?9V5T7V9R86<`<G1W7W=X7V=E
+M=%]R971R>0!R='=?=WA?9V5T7W!O=V5R`')T=U]W>%]W<FET95]R9@!R='=?
+M=WA?<')I=E]N=6QL`&1U;6UY`')T=U]W>%]S971?;71K7W=P<U]P<F]B95]I
+M90!R='=?=WA?9V5T7W-E;G-I=&EV:71Y`')T=U]W>%]S971?;71K7W=P<U]I
+M90!R='=?9')V97AT7VAD;`!R='=?<V5T7W!I9`!R='=?<#)P7W-E=`!R='=?
+M<#)P7V=E=`!R='=?<#)P7V=E=#(`<G1W7W1D;',`<G1W7V=E=%]W:7)E;&5S
+M<U]S=&%T<P!R='=?=WA?<F5A9%]R9@`N3$,P`')T=U]M<%]E9G5S95]G970`
+M+DQ#,0`N3$,R`"Y,0S4`+DQ#.``N3$,Q,0`N3$,Q,@`N3$,V`"Y,0S$S`"Y,
+M0S$T`"Y,0S$U`"Y,0S$V`"Y,0S$W`"Y,0S$X`"1D`')T=U]W<'-?<W1A<G0`
+M<G1W7VUP7V5F=7-E7W-E=``N3$,Q.0`N3$,R,`!R='=?<F5R96=?;F1?;F%M
+M90`N3$%.0TA/4C``+DQ#,C(`<G1W7W!M7W-E=``N3$,R,P`N3$,R-``N3$,R
+M-0!R='=?=WA?=W)I=&4S,@!R='=?9&)G7W!O<G0`<G1W7W=X7W-E=%]C:&%N
+M;F5L7W!L86X`<G1W7V=E=%]A<%]I;F9O`')T=U]M<%]I;V-T;%]H9&P`<G1W
+M7W=X7W)E860S,@`N3$,R-@!R='=?=WA?<V5T7W!M:VED`')T=U]W>%]G971?
+M96YC`')T=U]W>%]G971?;FEC:P`N3$,R-P!R='=?=WA?9V5T7V5S<VED`')T
+M=U]W>%]G971?=V%P`')T=U]W>%]S971?96YC`'=P85]S971?96YC<GEP=&EO
+M;@`N3$,R.`!R='=?=WA?<V5T7V5N8U]E>'0`+DQ#,CD`+DQ#,S``+DQ#,S$`
+M<G1W7W=X7W-E=%]A=71H`')T=U]S971?=W!A7VEE`"Y,04Y#2$]2,0!R='=?
+M=WA?<V5T7V=E;E]I90!R='=?=WA?9V5T7W)A=&4`<G1W7W=X7W-E=%]R871E
+M`')T=U]W>%]S971?97-S:60`<G1W7W=X7V=E=%]N86UE`"Y,0S,R`"Y,0S,S
+M`"Y,0S,T`"Y,0S,U`"Y,0S,V`"Y,0S,W`"Y,0S,X`"Y,0S,Y`"Y,0S0P`')T
+M=U]W>%]G971?<F%N9V4`+DQ!3D-(3U(R`')T=U]W>%]G971?9G)E<0!T<F%N
+M<VQA=&5?<V-A;@`N3$,T,0`N3$,T,P`N3$,T,@`N3$,T-``N3$,T-0`N3$,T
+M-@`N3$,T-P!R='=?=WA?9V5T7W-C86X`<G1W7W=X7W-E=%]M;&UE`')T=U]W
+M>%]S971?=V%P`')T=U]W>%]S971?<V-A;@!R='=?=WA?<V5T7W!R:78`+DQ#
+M-3(`+DQ#-30`+DQ#-34`+DQ#-38`+DQ#-3<`+DQ#-3@`+DQ#-3D`+DQ#-C``
+M+DQ#-C$`+DQ#-C(`+DQ#-C,`+DQ#-C0`+DQ#-C4`+DQ#-C8`<G1W7W=X7W-E
+M=%]M;V1E`'-E=%]G<F]U<%]K97D`<V5T7W=E<%]K97D`+DQ#-C<`0RXV,3DN
+M-#$Q-C0`0RXV-#8N-#$X.3``7U]F=6YC7U\N-#$T-C0`0RXW-3$N-#,W-3,`
+M0U-75$-(+C<X-`!#4U=40T@N-S@W`$,N-S,S+C0S-3(V`')T=U]P<FEV871E
+M7V%R9W,`<G1W7VAA;F1L97)S`')T=U]P<FEV871E7VAA;F1L97(`;VQD7VEF
+M;F%M92XT,C<Q-@!O;&1?8E)E9U5S94QE9"XT,C<Q.`!O;&1?:7!S7VUO9&4N
+M-#(W,3<`<G1L.#$X.%]S=7-P96YD7VQO8VL`7U]A96%B:5]U;G=I;F1?8W!P
+M7W!R,`!R='=?:7-?9FET7W)E9W5L871O<GE?9&]M86EN`'5I7W!I9`!M86-?
+M<F5G7V1U;7``8F)?<F5G7V1U;7``<F9?<F5G7V1U;7``<W!R:6YT9@!?<G1W
+M7VUE;7-E=`!?7V-O<'E?9G)O;5]U<V5R`%]?;65M>F5R;P!S=')S97``<W1R
+M8VUP`')T=U]E9G5S95]M87!?<F5A9`!S=')L96X`<VEM<&QE7W-T<G1O=6P`
+M14954T5?1V5T169U<V5$969I;FET:6]N`')T=U]E9G5S95]A8V-E<W,`969U
+M<V5?1V5T0W5R<F5N=%-I>F4`969U<V5?1V5T36%X4VEZ90!K97E?,F-H87(R
+M;G5M`')T=U]E9G5S95]M87!?=W)I=&4`<')I;G1K`%]?865A8FE?=6YW:6YD
+M7V-P<%]P<C$`:69N86UE`'-T<FYC<'D`<G1W7V-H86YG95]I9FYA;64`7W)T
+M=U]M96UC;7``<G1W7W-W7VQE9%]I;FET`')T=U]F<F5E7VYE='=O<FM?<75E
+M=64`<G1W7W-W7VQE9%]D96EN:70`<F9P=W)S=&%T95]C:&5C:P!J:69F:65S
+M`&UO9%]T:6UE<@!S=')?,F-H87(R;G5M`$QE879E06QL4&]W97)3879E36]D
+M90!S<V-A;F8`7W)T=U]W<FET93,R`%]R='=?=W)I=&4X`%]R='=?=W)I=&4Q
+M-@!R='=?9V5T7W-T86EN9F\`;&]C86Q?8FA?9&ES86)L90!R='=?96YD7V]F
+M7W%U975E7W-E87)C:`!L;V-A;%]B:%]E;F%B;&4`<G1W7W-E=%]C:'!L86Y?
+M8VUD`')T=U]M<VQE97!?;W,`<G1W7V=E=%]W<&%?:64`<G1W7V=E=%]W<&$R
+M7VEE`%]?8V]P>5]T;U]U<V5R`%]R='=?;6%L;&]C`%]R='=?<F5A9#@`7W)T
+M=U]R96%D,38`7W)T=U]R96%D,S(`7W)T=U]M9G)E90!?<G1W7VUE;6-P>0!R
+M='=?<V5T7S@P,E\Q,5]A9&1?=V5P`')T=U]S971?:V5Y`')T=U]S971S=&%K
+M97E?8VUD`')T=U]G971?8F-M8U]S=&%I;F9O`')T=U]D:7-A<W-O8U]C;60`
+M<G1W7VEN9&EC871E7V1I<V-O;FYE8W0`<G1W7V9R965?87-S;V-?<F5S;W5R
+M8V5S`%]R='=?>FUA;&QO8P!R='=?<&%R<V5?=W!A7VEE`')T=U]P87)S95]W
+M<&$R7VEE`')T=U]G971?:64`<G1W7W-E=&1A=&%R871E7V-M9`!R='=?<V5T
+M7S@P,E\Q,5]I;F9R87-T<G5C='5R95]M;V1E`')T=U]S971?.#`R7S$Q7V%U
+M=&AE;G1I8V%T:6]N7VUO9&4`<G1W7W-E=%\X,#)?,3%?<W-I9`!R='=?:7-?
+M8V-K<F%T97-O;FQY7VEN8VQU9&5D`'-N<')I;G1F`')T=U]I<U]C8VMR871E
+M<U]I;F-L=61E9`!R='=?8V@R9G)E<0!M96UC<'D`<G1W7W9A;&ED871E7W-S
+M:60`<G1W7V=E=%]C87!A8FEL:71Y7V9R;VU?:64`<G1W7V=E=%]S96-?:64`
+M<G1W7VES7W=P<U]I90!R='=?<V5T7S@P,E\Q,5]D:7-A<W-O8VEA=&4`<G1W
+M7W-E=%\X,#)?,3%?8G-S:60`<G1W7VEN9&EC871E7W=X7V1I<V%S<V]C7V5V
+M96YT`'=I<F5L97-S7W-E;F1?979E;G0`<G1W7VEN9&EC871E7W=X7V%S<V]C
+M7V5V96YT`&EN9&EC871E7W=X7W-C86Y?8V]M<&QE=&5?979E;G0`<G1W7W-I
+M=&5S=7)V97E?8VUD`')T=U]S971?.#`R7S$Q7V)S<VED7VQI<W1?<V-A;@!?
+M<G1W7W9M86QL;V,`7W)T=U]V;69R964`<W1R;F-M<`!W86ME7VQO8VL`<VQE
+M97!?<F5S=6UE`&US;&5E<`!W86ME7W5N;&]C:P!I;FET7V-H86YN96Q?<&QA
+M;@!R='=?<V5T;W!M;V1E7V-M9`!?<G1W7VEN:71?;&ES=&AE860`<G1W7V5N
+M<75E=65?8VUD`')T=U]I;V-T;`!F;'5S:%]A;&Q?8V%M7V5N=')Y`')T=U]S
+M=&%?9FQU<V@`=7!D871E7W-T85]I;F9O7V%P;6]D90!A<%]F<F5E7W-T80!R
+M='=?8VAE8VM?8F5A8V]N7V1A=&$`=7!D871E7V)E86-O;@!R=&PX,3@X7W!O
+M=V5R7W-A=F5?97AI=`!W86ME7VQO8VM?9&5S=')O>0!R=&PX,3@X7W!O=V5R
+M7W-A=F5?:6YI=`!W86ME7VQO8VM?:6YI=`!R='=?<F%T97,`86YD<F]I9%]W
+M:69I7V-M9%]S='(`<G1L.#$X.%]W86ME;&]C:U]I;FET`')T=U]H86YD;&5R
+M<U]D968`````7`,``"O^``!@`P``+/X``-P$```K.P``X`0``"P[``#H!```
+M'`(!`#0%```<`P$`1`4``!P#`0!\!0``'`0!`)P%```<!0$`P`4``"L^``#$
+M!0``+#X``.P%```<!@$```8``"L_```$!@``+#\```@&```<!P$`)`8``!P(
+M`0`\!@``'`,!`$P&```<`@$`6`8``"M```!<!@``+$```'`&```<`@$`E`8`
+M`!P"`0"P!@``'`(!`,0&```<`@$`Y`8``!P"`0#X!@``'`D!``P'```K00``
+M$`<``"Q!```4!P``'`<!`$0'```<"@$`6`<``!P*`0",!P``'`L!`+@'```<
+M"`$`R`<``!P#`0#P!P``'`(!```(```<`@$`%`@``!P)`0`L"```*T(``#`(
+M```L0@``-`@``!P'`0!8"```'`P!`'`(```<`P$`>`@``"M#``!\"```+$,`
+M`(0(```K1```B`@``"Q$``","```*T4``)`(```L10``I`@``!P"`0#`"```
+M'`(!`.`(```<`@$`]`@``!P)`0`("0``*T8```P)```L1@``$`D``!P'`0!4
+M"0``'`L!`'@)```<"`$`B`D``!P#`0"L"0``'`(!`+P)```<`@$`T`D``!P)
+M`0#D"0``*T<``.@)```L1P``[`D``!P'`0`P"@``'`L!`%0*```<"`$`9`H`
+M`!P#`0"("@``'`(!`)@*```<`@$`K`H``!P)`0#`"@``*T@``,0*```L2```
+MR`H``!P'`0#H"@``'`T!`/`*```<#@$`!`L``"M)```("P``+$D``!`+```<
+M`@$`&`L``!P)`0`L"P``*TH``#`+```L2@``.`L``!P"`0!`"P``'`D!`&0+
+M```"\P``:`L```+S``!L"P```O,``'`+```"\P``=`L```+S``!X"P```O,`
+M`,@+```<!`$`V`L``!P%`0#<#```*SX``.`,```L/@``!`T``!P&`0`8#0``
+M*U```!P-```L4```(`T``!P'`0!,#0``'`H!`%@-```<"0$`>`T``!P/`0"T
+M#0``'`L!`-P-```<$`$`\`T``"M1``#T#0``+%$``/@-```<!P$`)`X``!P*
+M`0`P#@``'`D!`%`.```<#P$`@`X``!P,`0"4#@``*T8``)@.```L1@``G`X`
+M`!P'`0#$#@``'`D!`.P.```<#P$`)`\``!P+`0!,#P``'!`!`&`/```K1P``
+M9`\``"Q'``!H#P``'`<!`)`/```<"0$`L`\``!P/`0#H#P``'`L!`!`0```<
+M$`$`)!```!P1`0!,$````O,``&`0```K50``9!```"Q5``!X$```*Q,!`'P0
+M```L$P$`C!```!P4`0#4$```'`0!`.P0```<!0$`^!```"M5``#\$```+%4`
+M``01```<!P$`'!$``!P5`0`H$0``*U4``"P1```L50``,!$``"M6```T$0``
+M+%8``#P1```<%@$`7!$``!P7`0!L$0``*U4``'`1```L50``A!$``!P4`0"4
+M$0``*U8``)@1```L5@``H!$``!P6`0"T$0``'!@!`/`1```<&0$`&!(```($
+M``"4$@``*QL!`)@2```L&P$`R!(``!P<`0``$P``*UL```03```L6P``#!,`
+M`!P6`0!D$P``'!T!`)P3```<'@$`O!,``"M<``#`$P``+%P``,@3```<%@$`
+M]!,``"M=``#X$P``+%T``/P3```<'P$`(!0``"L;`0`D%```+!L!`%04```<
+M'`$`:!0``!P:`0"4%```'"`!`-04```"`@``V!0```("``#<%````@(``.`4
+M```"`@``Y!0```("``#H%````@(``.P4```"`@``\!0```("``#T%````@(`
+M`/@4```"`@``_!0```("````%0```@(```05```"`@``"!4```("```,%0``
+M`@(``#05```<(0$`2!4``!PB`0!<%0``'"`!`$06```<(P$`C!8``!PD`0#4
+M%@``'"4!``@7```<)@$`1!<``!S_``!8%P``'``!`&P7```<`0$`W!<``!PA
+M`0#L%P``'"$!`!`8```<)P$`:!@``!PH`0#(&```'`0!`.`8```<!0$`[!@`
+M`!PD`0`H&0``'"4!`*@9```<)@$`R!D``!PI`0#\&0``'"H!`$0:```<)@$`
+MB!H``!PK`0"\&@``'!8!```;```<+`$`0!L``!P$`0!@&P``'`4!`-P;```<
+M+0$`\!L``!PN`0`$'```'"\!`#@<```<(0$`3!P``!PB`0!@'```'"`!``P=
+M```<*P$`1!T``!PP`0!<'0``'"\!`&@=```K;```;!T``"QL``!T'0``'`(!
+M`+`=```<,0$`S!T``!P6`0``'@``'!8!`"0>```<,0$`G!X``!P6`0#`'@``
+M'`,!``@?```<`P$`5!\``!PQ`0!P'P``'#$!`"@@```"`@``+"````("```P
+M(````@(``#0@```"`@``."````("```\(````@(``$`@```"`@``C"```!PQ
+M`0`H(0``*W4``"PA```L=0``-"$``!PQ`0!X(0``'#$!`+`A```<`P$`W"$`
+M`!PQ`0#P(0``'`,!`!PB```<`P$`[",``!PQ`0#X(P``'#(!`(@D```K?@``
+MC"0``"Q^``"0)```'`<!`.PD```<+`$`!"4``!P#`0!`)0``'#$!`%@E```<
+M,@$`A"4``!PQ`0"H)0``'#,!`.@E```<(P$`_"4``!P'`0!,)@``'#$!`%@F
+M```<!P$`<"8``!PQ`0"`)@``'#$!`)PF```<-`$`R"8``!PQ`0#L)@``'#$!
+M``PG```<,0$`-"<``!PS`0`\)P``'#4!`%`G```<!P$`L"<``!PP`0"X)P``
+M`O,``+PG```"\P``W"<``!PL`0#X)P``'`,!`!`H```<`P$`)"@```("```H
+M*````@(``"PH```"`@``,"@```("```T*```*WX``#@H```L?@``0"@``"N$
+M``!$*```+(0``$PH```KA0``4"@``"R%``!8*```*X8``%PH```LA@``;"@`
+M`!P4`0"T*```'#$!`-0H```<,0$`]"@``!PP`0`P*0```@(``#0I```"`@``
+M."D```("```\*0```@(``$`I```"`@``1"D```("``!(*0```@(``$PI```"
+M`@``4"D```("``!4*0```@(``%@I```"`@``["D``!PV`0#T*0``'#<!`/PI
+M```<.`$`D"H``!PY`0"L*@``'#$!`-`J```<.@$`!"L``!P[`0`\*P```@(`
 M`$`K```"`@``1"L```("``!(*P```@(``$PK```"`@``4"L```("``!4*P``
-M`@(``%@K```"`@``7"L```("``!@*P```@(````L```"`@``!"P```("```(
-M+````@(```PL```"`@``$"P```("```4+````@(``!@L```"`@``'"P```("
+M`@(``%@K```"`@``7"L```("``!@*P```@(``&0K```"`@``:"L```("``!L
+M*P```@(``'`K```"`@``="L```("``!X*P```@(``!@L```"`@``'"P```("
 M```@+````@(``"0L```"`@``*"P```("```L+````@(``#`L```"`@``-"P`
-M``("```X+````@(``#PL```"`@``V"P``"N1``#<+```+)$``!`M```<%@$`
-M2"T``!PQ`0"8+0``*Y$``)PM```LD0``O"T``!PP`0`H+@``'#P!`%`N```<
-M,0$`O#```!P]`0#4,````N8``/`P```<&@$`7#$``!P#`0!T,0``'#$!`)`Q
-M```<)0$`M#$``!P6`0#T,0``'#X!``@R```</P$`%#(``!Q``0!P,@``'#P!
-M`)0R```<00$`L#(``"N=``"T,@``+)T``+@R```<0@$`R#(``"N>``#,,@``
-M+)X``-`R```<0@$`W#(``!Q#`0#X,@``*Y\``/PR```LGP```#,``!Q"`0`0
-M,P``*Z```!0S```LH```&#,``!Q"`0`\,P``*Z$``$`S```LH0``1#,``!Q"
-M`0!4,P``*Z(``%@S```LH@``7#,``!Q"`0!T,P``*Z,``'@S```LHP``?#,`
-M`!Q"`0",,P``*Z0``)`S```LI```E#,``!Q"`0"D,P``*Z4``*@S```LI0``
-MK#,``!Q"`0#<,P``'`,!`"@T```KJ```+#0``"RH``"D-```'$0!`!@U```<
-M1`$`1#4``!Q$`0"X-0``'#$!`.0U```<10$`]#4``!Q%`0``-@``'$8!`&0V
-M```<10$`=#8``!Q%`0"(-@``'$4!`+`V```</`$`W#8``!PQ`0`X-P``'$$!
-M`%@W```KG0``7#<``"R=``!@-P``'$(!`'`W```KG@``=#<``"R>``!X-P``
-M'$(!`(0W```<0P$`I#<``"N?``"H-P``+)\``*PW```<0@$`O#<``"N@``#`
-M-P``+*```,0W```<0@$`[#<``"NA``#P-P``+*$``/0W```<0@$`!#@``"NB
-M```(.```+*(```PX```<0@$`*#@``"NC```L.```+*,``#`X```<0@$`0#@`
-M`"ND``!$.```+*0``$@X```<0@$`=#@``!Q%`0"$.```'$4!`*@X```<1P$`
-MO#@``!PQ`0`0.0``'$4!`"`Y```<10$`4#D``!Q$`0"@.0``'$4!`+`Y```<
-M10$`(#H``!Q%`0`P.@``'$4!`$0Z```<10$`6#H``"NM``!<.@``+*T``&`Z
-M```<0@$`B#H``"NN``",.@``+*X``)0Z```KKP``G#H``"RO``"@.@``*[``
-M`*0Z```LL```Y#H``!Q"`0`D/```'$4!`#0\```<10$`;#P``!Q(`0"0/```
-M'`,!`)0\```KL0``F#P``"RQ``#`/```*[(``,0\```LL@``W#P``!P"`0`$
-M/0``'`,!`!P]```<"0$`6#T``!Q%`0!H/0``'$4!`'P]```<10$`D#T``!P#
-M`0#</0``'$4!`.P]```<10$``#X``!Q%`0`H/@``'`,!`"P^```KLP``,#X`
-M`"RS``!8/@``*[(``%P^```LL@``=#X``!P"`0"</@``'`,!`+0^```<"0$`
-M\#X``!Q%`0``/P``'$4!`!0_```<10$`*#\``!P#`0!T/P``'$4!`(0_```<
-M10$`F#\``!Q%`0`40```'$D!`'1````<10$`A$```!Q%`0"80```'$4!`!A!
-M```<10$`*$$``!Q%`0"`00``'"0!`+Q!```<)0$`]$$``!S]``!`0@``'"8!
-M`)A"```<2@$`K$(``!Q*`0#<0@``'!H!`/!"```<$0$`($,``!P1`0!00P``
-M'"4!`&1#```<2P$`C$,``!P6`0"@0P``'#X!`+1#```</P$`P$,``!Q+`0#@
-M0P```O,``.1#```"Y@``Z$,```+S```(1```'`,!`"!$```<`P$`.$0``!Q-
-M`0!@1```'`,!`'A$```<,0$`D$0``!Q-`0"X1```'`,!`-!$```<30$`]$0`
-M`!P:`0!`10``'$\!`%Q%```<3P$`G$4``!P#`0"L10``'#$!`+1%```<)`$`
-MV$4``!Q0`0#L10``'"8!``A&```<%@$`+$8``!P#`0!01@``'!\!`'A&```<
-M'P$`G$8``!PQ`0"T1@``'"0!`-A&```<4`$`[$8``!PF`0#X1@``'%$!`!Q'
-M```"Y@``($<```+S``!,1P``'%(!`(Q'```<!`$`K$<``!P%`0"X1P``'%,!
-M`.A'```KD0``[$<``"R1```02```'!8!`#1(```<,0$`:$@``!P6`0#$2```
-M'`D!`-1(```<5`$`_$@```("````20```@(```1)```"`@``"$D```("```,
-M20```@(``!!)```"`@``%$D```("```820```@(``!Q)```"`@``($D``"O%
-M```D20``+,4``"A)```<$0$`+$D``"M5```P20``+%4``$A)```<50$`5$D`
-M`"M6`0!820``+%8!`'A)```<$0$`@$D``!Q7`0"420``*\8``)A)```LQ@``
-MS$D``!Q-`0#420``*\<``-A)```LQP``X$D``!Q%`0#H20``*\@``.Q)```L
-MR```\$D``!P1`0#X20``*\D``/Q)```LR0``,$H``!Q-`0`X2@``*\<``#Q*
-M```LQP``1$H``!Q%`0!(2@``*U4``$Q*```L50``9$H``!Q8`0"$2@``*\H`
-M`(A*```LR@``E$H``!P"`0"@2@``*\<``*1*```LQP``K$H``!Q%`0#L2@``
-M*\L``/!*```LRP``^$H``!P"`0`P2P``*\P``#1+```LS```.$L``!P"`0!,
-M2P``*\<``%!+```LQP``6$L``!Q%`0!L2P``*\<``'!+```LQP``>$L``!Q%
-M`0"(2P``*\T``(Q+```LS0``E$L``!P?`0"<2P``*\X``*!+```LS@``I$L`
-M`!P'`0"\2P``*\\``,!+```LSP``Q$L``!P'`0#<2P``*]```.!+```LT```
-MY$L``!P'`0#T2P``*UD!`/A+```L60$`%$P``!PQ`0`P3```*\<``#1,```L
-MQP``/$P``!Q%`0!$3```*UD!`$A,```L60$`>$P``"O1``!\3```+-$``(1,
-M```<`@$`B$P``"M9`0",3```+%D!`)!,```KT@``E$P``"S2``"@3```'!$!
-M`*Q,```KQP``L$P``"S'``"X3```'$4!`,A,```<"0$`#$T``!PK`0`L30``
-M'%,!`#Q-```"Y@``0$T```(#``!$30```O,``$A-```"5@$`7$T``!P:`0",
-M30```@(``)!-```"`@``E$T```("``"830```@(``,A-```</@$`W$T``!Q:
-M`0`,3@``'#D!`"A.```<.0$`/$X``!PP`0!43@``'`,!`'A.```KD0``?$X`
-M`"R1``"43@``'#$!`+A.```<6P$`Q$X``!Q<`0#H3@``*Y$``.Q.```LD0``
-M2$\``!PL`0"03P``'`0!`*Q/```<!0$`N$\``!PP`0#83P```@(``-Q/```"
-M`@``X$\```("``#D3P```@(``/Q0```<2@$`$%$``!Q*`0!D40``'"L!`'Q1
-M```<,`$`O%$``!PL`0`$4@``'`0!`"!2```<!0$`+%(``!PP`0!,4@```@(`
-M`%!2```"`@``5%(```("``!84@```@(``%Q2```"`@``8%(```("``!D4@``
-M`@(``&A2```"`@``;%(```("``!P4@```@(``'12```"`@``>%(```("``!\
-M4@```@(``(!2```"`@``A%(```("``"(4@```@(``(Q2```"`@``D%(```("
-M``"44@```@(``*A2```<7@$`L%(``!Q?`0#T4@``'",!`!Q3```<,0$`;%,`
-M`!PQ`0"$4P``'&`!`-!3```<(P$`Z%,``!QA`0`@5```'#$!`$Q4```<8@$`
-MP%0``!PC`0#<5```'`<!`/!4```<!P$`3%4``!PL`0!D50``'`,!`(15```<
-M,0$`[%4``!PQ`0`T5@``'#$!`*Q6```<,0$`W%8``!P'`0`85P``'#$!`#17
-M```<,0$`4%<``!PQ`0!L5P``'`<!`*17```<,0$`^%<``!PU`0!P6```'#$!
-M`'Q8```<!P$`K%@``!P'`0#,6```'#$!`-Q8```<,0$`^%@``!P'`0`460``
-M'#D!`"A9```<.0$`/%D``!PP`0!(60``'%L!`(!9```<,0$`D%D``!PQ`0"<
-M60``'%P!`-19```<,0$`!%H``!P'`0!`6@``'#$!`%Q:```<,0$`>%H``!PQ
-M`0"46@``'`<!`,Q:```<,0$`(%L``!PU`0!46P``'#`!`)A;```<(P$`W%L`
-M`!PQ`0`D7```'#`!`$!<```<+`$`7%P``!PQ`0!P7```'&,!`+A<```<,`$`
-MU%P``!PL`0#P7```'#$!`"Q=```<,`$`2%T``!PL`0!D70``'#$!`+!=```<
-M*P$`R%T``!PP`0#D70``'`<!``A>```"\P``#%X```+S```07@```O,``!1>
-M```"\P``&%X```+F```@7@``*U4``"1>```L50``-%X``!Q7`0!(7@``'%@!
-M`%!>```<90$`6%X```($``!@7@``*U4``&1>```L50``=%X``"OE``!X7@``
-M+.4``'Q>```<9P$`A%X``!Q5`0`P`````O,``#0````"\P``.`````+S```\
-M`````O,``$`````"\P``1`````+S``!(`````O,``$P````"\P``4`````+S
-M``!<`````@,``&`````"`P``9`````+F``!H`````C<``'`````"FP``=```
-M``(@``!X`````B```'P````""P``@`````*I``"$`````M0``(@````"#0``
-MC`````(@``"0`````@\``)@````"I@``G`````+!``"L`````B```+`````"
-M(```O`````*X``#``````G@``,0````"M@``R`````(@``#,`````KX``-``
-M```"M```U`````*9``#8`````G8``-P````"(```X`````)S``#L`````I8`
-M`/`````"E```]`````(@``#X`````A(``/P````"%`````$```(6```$`0``
-M`B````@!```"(```#`$```(@```0`0```A@``!0!```">@``&`$```)O```<
-M`0```B```"`!```"&@``+`$```*2```T`0```H<``#P!```"@```1`$```)M
-M``!,`0```EX``%`!```":@``5`$```(H``!8`0```F@``%P!```"9@``8`$`
-M``(J``!D`0```DP``&@!```")```;`$```(B``!P`0```B8``'0!```"9```
-M>`$```)@``!\`0```AP``(`!```".0``A`$```(>``"(`0```AX``(P!```"
-M+```D`$```(N``"4`0```C```)P!```"-0``H`$```(>``"D`0```ED``*@!
-M```"'@``K`$```)3``"P`0```AX``+0!```"3@``N`$```(\````````*@(`
-M````````_```"````"H"```0````*@(``!@````J`@``(````"H"```H````
-M*@(``#`````J`@``.````"H"``!`````*@(``$@````J`@``4````"H"``!8
-M````*@(``&`````J`@``:````"H"``!P````*@(``'@````J`@``@````"H"
-M``"(````*@(``)`````J`@``F````"H"``"@````*@(``*@````J`@``L```
-M`"H"``"X````*@(``,`````J`@``R````"H"``#0````*@(``-@````J`@``
-MX````"H"``#H````*@(``/`````J`@``\``````2`0#T````*@<``/@````J
-M`@````$``"H"```(`0``*@(``!`!```J`@``&`$``"H"```@`0``*@(``"@!
-M```J`@``,`$``"H"```X`0``*@(``$`!```J`@``2`$``"H"``!0`0``*@(`
-M`%@!```J`@``8`$``"H"``!H`0``*@(``'`!```J`@``>`$``"H"``"``0``
-M*@(``(@!```J`@``D`$``"H"``"8`0``*@(``*`!```J`@``J`$``"H"``"P
-M`0``*@(``+@!```J`@``P`$``"H"``#(`0``*@(``-`!```J`@``V`$``"H"
-M``#@`0``*@(``.@!```J`@``\`$``"H"``#X`0``*@(````"```J`@``"`(`
-M`"H"```0`@``*@(``!@"```J`@``(`(``"H"```H`@``*@(``#`"```J`@``
-(.`(``"H"````
+M``("```X+````@(``#PL```"`@``0"P```("``!$+````@(``$@L```"`@``
+M3"P```("``!0+````@(``%0L```"`@``\"P``"N1``#T+```+)$``"@M```<
+M%@$`8"T``!PQ`0"P+0``*Y$``+0M```LD0``U"T``!PP`0!`+@``'#P!`&@N
+M```<,0$`U#```!P]`0#L,````N8```@Q```<&@$`=#$``!P#`0",,0``'#$!
+M`*@Q```<)0$`S#$``!P6`0`,,@``'#X!`"`R```</P$`+#(``!Q``0"(,@``
+M'#P!`*PR```<00$`R#(``"N=``#,,@``+)T``-`R```<0@$`X#(``"N>``#D
+M,@``+)X``.@R```<0@$`]#(``!Q#`0`0,P``*Y\``!0S```LGP``&#,``!Q"
+M`0`H,P``*Z```"PS```LH```,#,``!Q"`0!4,P``*Z$``%@S```LH0``7#,`
+M`!Q"`0!L,P``*Z(``'`S```LH@``=#,``!Q"`0",,P``*Z,``)`S```LHP``
+ME#,``!Q"`0"D,P``*Z0``*@S```LI```K#,``!Q"`0"\,P``*Z4``,`S```L
+MI0``Q#,``!Q"`0#T,P``'`,!`$`T```KJ```1#0``"RH``"\-```'$0!`#`U
+M```<1`$`7#4``!Q$`0#0-0``'#$!`/PU```<10$`##8``!Q%`0`8-@``'$8!
+M`'PV```<10$`C#8``!Q%`0"@-@``'$4!`,@V```</`$`]#8``!PQ`0!0-P``
+M'$$!`'`W```KG0``=#<``"R=``!X-P``'$(!`(@W```KG@``C#<``"R>``"0
+M-P``'$(!`)PW```<0P$`O#<``"N?``#`-P``+)\``,0W```<0@$`U#<``"N@
+M``#8-P``+*```-PW```<0@$`!#@``"NA```(.```+*$```PX```<0@$`'#@`
+M`"NB```@.```+*(``"0X```<0@$`0#@``"NC``!$.```+*,``$@X```<0@$`
+M6#@``"ND``!<.```+*0``&`X```<0@$`C#@``!Q%`0"<.```'$4!`,`X```<
+M1P$`U#@``!PQ`0`H.0``'$4!`#@Y```<10$`:#D``!Q$`0"X.0``'$4!`,@Y
+M```<10$`.#H``!Q%`0!(.@``'$4!`%PZ```<10$`<#H``"NM``!T.@``+*T`
+M`'@Z```<0@$`H#H``"NN``"D.@``+*X``*PZ```KKP``M#H``"RO``"X.@``
+M*[```+PZ```LL```_#H``!Q"`0`\/```'$4!`$P\```<10$`A#P``!Q(`0"H
+M/```'`,!`*P\```KL0``L#P``"RQ``#8/```*[(``-P\```LL@``]#P``!P"
+M`0`</0``'`,!`#0]```<"0$`<#T``!Q%`0"`/0``'$4!`)0]```<10$`J#T`
+M`!P#`0#T/0``'$4!``0^```<10$`&#X``!Q%`0!`/@``'`,!`$0^```KLP``
+M2#X``"RS``!P/@``*[(``'0^```LL@``C#X``!P"`0"T/@``'`,!`,P^```<
+M"0$`"#\``!Q%`0`8/P``'$4!`"P_```<10$`0#\``!P#`0",/P``'$4!`)P_
+M```<10$`L#\``!Q%`0`L0```'$D!`(Q````<10$`G$```!Q%`0"P0```'$4!
+M`#!!```<10$`0$$``!Q%`0"800``'"0!`-1!```<)0$`#$(``!S]``!80@``
+M'"8!`+!"```<2@$`Q$(``!Q*`0#T0@``'!H!``A#```<$0$`.$,``!P1`0!H
+M0P``'"4!`'Q#```<2P$`I$,``!P6`0"X0P``'#X!`,Q#```</P$`V$,``!Q+
+M`0#X0P```O,``/Q#```"Y@```$0```+S```@1```'`,!`#A$```<`P$`4$0`
+M`!Q-`0!X1```'`,!`)!$```<,0$`J$0``!Q-`0#01```'`,!`.A$```<30$`
+M#$4``!P:`0!810``'$\!`'1%```<3P$`M$4``!P#`0#$10``'#$!`,Q%```<
+M)`$`\$4``!Q0`0`$1@``'"8!`"!&```<%@$`1$8``!P#`0!H1@``'!\!`)!&
+M```<'P$`M$8``!PQ`0#,1@``'"0!`/!&```<4`$`!$<``!PF`0`01P``'%$!
+M`#1'```"Y@``.$<```+S``!D1P``'%(!`*1'```<!`$`Q$<``!P%`0#01P``
+M'%,!``!(```KD0``!$@``"R1```H2```'!8!`$Q(```<,0$`@$@``!P6`0#<
+M2```'`D!`.Q(```<5`$`%$D```("```820```@(``!Q)```"`@``($D```("
+M```D20```@(``"A)```"`@``+$D```("```P20```@(``#1)```"`@``.$D`
+M`"O%```\20``+,4``$!)```<$0$`1$D``"M5``!(20``+%4``&!)```<50$`
+M;$D``"M6`0!P20``+%8!`)!)```<$0$`F$D``!Q7`0"L20``*\8``+!)```L
+MQ@``Y$D``!Q-`0#L20``*\<``/!)```LQP``^$D``!Q%`0``2@``*\@```1*
+M```LR```"$H``!P1`0`02@``*\D``!1*```LR0``2$H``!Q-`0!02@``*\<`
+M`%1*```LQP``7$H``!Q%`0!@2@``*U4``&1*```L50``?$H``!Q8`0"<2@``
+M*\H``*!*```LR@``K$H``!P"`0"X2@``*\<``+Q*```LQP``Q$H``!Q%`0`$
+M2P``*\L```A+```LRP``$$L``!P"`0!(2P``*\P``$Q+```LS```4$L``!P"
+M`0!D2P``*\<``&A+```LQP``<$L``!Q%`0"$2P``*\<``(A+```LQP``D$L`
+M`!Q%`0"@2P``*\T``*1+```LS0``K$L``!P?`0"T2P``*\X``+A+```LS@``
+MO$L``!P'`0#42P``*\\``-A+```LSP``W$L``!P'`0#T2P``*]```/A+```L
+MT```_$L``!P'`0`,3```*UD!`!!,```L60$`+$P``!PQ`0!(3```*\<``$Q,
+M```LQP``5$P``!Q%`0!<3```*UD!`&!,```L60$`D$P``"O1``"43```+-$`
+M`)Q,```<`@$`H$P``"M9`0"D3```+%D!`*A,```KT@``K$P``"S2``"X3```
+M'!$!`,1,```KQP``R$P``"S'``#03```'$4!`.!,```<"0$`)$T``!PK`0!$
+M30``'%,!`%1-```"Y@``6$T```(#``!<30```O,``&!-```"5@$`=$T``!P:
+M`0"D30```@(``*A-```"`@``K$T```("``"P30```@(``.!-```</@$`]$T`
+M`!Q:`0`D3@``'#D!`$!.```<.0$`5$X``!PP`0!L3@``'`,!`)!.```KD0``
+ME$X``"R1``"L3@``'#$!`-!.```<6P$`X$X``!Q<`0`$3P``*Y$```A/```L
+MD0``9$\``!PL`0"L3P``'`0!`,A/```<!0$`U$\``!PP`0#T3P```@(``/A/
+M```"`@``_$\```("````4````@(``!A1```<2@$`+%$``!Q*`0"`40``'"L!
+M`)A1```<,`$`V%$``!PL`0`@4@``'`0!`#Q2```<!0$`2%(``!PP`0!H4@``
+M`@(``&Q2```"`@``<%(```("``!T4@```@(``'A2```"`@``?%(```("``"`
+M4@```@(``(12```"`@``B%(```("``",4@```@(``)!2```"`@``E%(```("
+M``"84@```@(``)Q2```"`@``H%(```("``"D4@```@(``*A2```"`@``K%(`
+M``("``"P4@```@(``,12```<7@$`S%(``!Q?`0`04P``'",!`#A3```<,0$`
+MB%,``!PQ`0"@4P``'&`!`.Q3```<(P$`!%0``!QA`0`\5```'#$!`&A4```<
+M8@$`W%0``!PC`0#X5```'`<!``Q5```<!P$`:%4``!PL`0"`50``'`,!`*!5
+M```<,0$`"%8``!PQ`0!(5@``'#$!`+Q6```<,0$`[%8``!P'`0`H5P``'#$!
+M`$Q7```<,0$`;%<``!PQ`0"(5P``'`<!`,!7```<,0$`%%@``!PU`0",6```
+M'#$!`)A8```<!P$`R%@``!P'`0#H6```'#$!`/A8```<,0$`%%D``!P'`0`P
+M60``'#D!`$19```<.0$`6%D``!PP`0!D60``'%L!`)Q9```<,0$`K%D``!PQ
+M`0"\60``'%P!`/19```<,0$`)%H``!P'`0!@6@``'#$!`(1:```<,0$`I%H`
+M`!PQ`0#`6@``'`<!`/A:```<,0$`3%L``!PU`0"`6P``'#`!`,1;```<(P$`
+M"%P``!PQ`0!07```'#`!`&Q<```<+`$`B%P``!PQ`0"<7```'&,!`.1<```<
+M,`$``%T``!PL`0`<70``'#$!`%A=```<,`$`=%T``!PL`0"070``'#$!`-Q=
+M```<*P$`]%T``!PP`0`07@``'`<!`#1>```"\P``.%X```+S```\7@```O,`
+M`$!>```"\P``1%X```+F``!,7@``*U4``%!>```L50``8%X``!Q7`0!T7@``
+M'%@!`'Q>```<90$`A%X```($``",7@``*U4``)!>```L50``H%X``"OE``"D
+M7@``+.4``*A>```<9P$`L%X``!Q5`0`P`````O,``#0````"\P``.`````+S
+M```\`````O,``$`````"\P``1`````+S``!(`````O,``$P````"\P``4```
+M``+S``!4`````@,``&`````"`P``9`````+F``!H`````C<``'`````"FP``
+M=`````(@``!X`````B```'P````""P``@`````*I``"$`````M0``(@````"
+M#0``C`````(@``"0`````@\``)@````"I@``G`````+!``"L`````B```+``
+M```"(```O`````*X``#``````G@``,0````"M@``R`````(@``#,`````KX`
+M`-`````"M```U`````*9``#8`````G8``-P````"(```X`````)S``#L````
+M`I8``/`````"E```]`````(@``#X`````A(``/P````"%`````$```(6```$
+M`0```B````@!```"(```#`$```(@```0`0```A@``!0!```">@``&`$```)O
+M```<`0```B```"`!```"&@``+`$```*2```T`0```H<``#P!```"@```1`$`
+M``)M``!,`0```EX``%`!```":@``5`$```(H``!8`0```F@``%P!```"9@``
+M8`$```(J``!D`0```DP``&@!```")```;`$```(B``!P`0```B8``'0!```"
+M9```>`$```)@``!\`0```AP``(`!```".0``A`$```(>``"(`0```AX``(P!
+M```"+```D`$```(N``"4`0```C```)P!```"-0``H`$```(>``"D`0```ED`
+M`*@!```"'@``K`$```)3``"P`0```AX``+0!```"3@``N`$```(\````````
+M*@(`````````_```"````"H"```0````*@(``!@````J`@``(````"H"```H
+M````*@(``#`````J`@``.````"H"``!`````*@(``$@````J`@``4````"H"
+M``!8````*@(``&`````J`@``:````"H"``!P````*@(``'@````J`@``@```
+M`"H"``"(````*@(``)`````J`@``F````"H"``"@````*@(``*@````J`@``
+ML````"H"``"X````*@(``,`````J`@``R````"H"``#0````*@(``-@````J
+M`@``X````"H"``#H````*@(``/`````J`@``\``````2`0#T````*@<``/@`
+M```J`@````$``"H"```(`0``*@(``!`!```J`@``&`$``"H"```@`0``*@(`
+M`"@!```J`@``,`$``"H"```X`0``*@(``$`!```J`@``2`$``"H"``!0`0``
+M*@(``%@!```J`@``8`$``"H"``!H`0``*@(``'`!```J`@``>`$``"H"``"`
+M`0``*@(``(@!```J`@``D`$``"H"``"8`0``*@(``*`!```J`@``J`$``"H"
+M``"P`0``*@(``+@!```J`@``P`$``"H"``#(`0``*@(``-`!```J`@``V`$`
+M`"H"``#@`0``*@(``.@!```J`@``\`$``"H"``#X`0``*@(````"```J`@``
+M"`(``"H"```0`@``*@(``!@"```J`@``(`(``"H"```H`@``*@(``#`"```J
++`@``.`(``"H"````
 `
 end
index a0789f01d5821bd0a291fa85797b2ceff8d448e3..4e418bc80b74e1d62acce887c7d9e1c8e340ce02 100644 (file)
@@ -45,7 +45,7 @@ struct wifi_power power_gpio =
 #define GPIO_WIFI_POWER       RK29_PIN6_PC0
 
        // YIFANG M803
-               POWER_USE_GPIO, 0, 
+               POWER_NOT_USE_GPIO/*POWER_USE_GPIO*/, 0, 
                0, 0, GPIO_WIFI_POWER, GPIO_HIGH
        
        //SDK
index aa49464d0535f9385496f353c7103e52b08ef1dc..e60ef105a17feb7a6a0c62ad044c132a2f30d331 100755 (executable)
@@ -7,7 +7,7 @@
 /*
  * Broadcom BCM4319 driver version.
  */
-#define RTL8192_DRV_VERSION "3.23"
+#define RTL8192_DRV_VERSION "3.26"
 
 #endif /* WIFI_BCM4319_VERSION_H */
 
old mode 100755 (executable)
new mode 100644 (file)
index fe019ca..d86bc0c
@@ -149,6 +149,7 @@ typedef struct _gcsHAL_INTERFACE
         {
             /* Physical memory address of internal memory. */
             OUT gctUINT32               baseAddress;
+            OUT gctCHAR                 fwVersion[20];
         }
         GetBaseAddress;
 
old mode 100755 (executable)
new mode 100644 (file)
index 72d8086..d98fa36
 #endif
 
 /* ============================== add by rockchip ===================================*/
+/*
+    dkm : GPU_FW_VERSION
+    
+    GPU¹Ì¼þ°æ±¾(×î´ó19¸ö×Ö·û´®)
+*/
+#define GPU_FW_VERSION                      "2.2.2"
+
+
+/*
+    dkm : BUILD_FOR_1_28
+    
+    ³ö1.28°æ±¾²¹¶¡ÓÃ
+    0: Ä¬ÈϱàÒë
+    1: ±àÒë1.28¿ÉÓõÄdriver
+*/
+#define BUILD_FOR_1_28                      0                  
+
+
 /*
     dkm : gcdENABLE_AUTO_FREQ
     0: ¹Ø±Õ×Ô¶¯µ÷Ƶ
 */
 #define gcdkUSE_MAPED_NONPAGE_CACHE         20
 
+
+/*
+    dkm : USE_DMA_COHERENT
+
+    use dma_alloc_* to alloc no page memory
+    USE_DMA_COHERENT : 
+        0  - no use  
+        1  - use
+*/
+#define USE_DMA_COHERENT                    1
+
+
 #endif /* __gc_hal_options_h_ */
 
old mode 100755 (executable)
new mode 100644 (file)
index ffb10bc..2363d83
@@ -19,8 +19,7 @@
 *****************************************************************************/
 
 
-
-
+#include <linux/string.h>
 #include "gc_hal_kernel_precomp.h"
 
 #define _GC_OBJ_ZONE    gcvZONE_KERNEL
@@ -293,7 +292,7 @@ _AllocateMemory(
     
 #if (0==gcdPAGE_ALLOC_LIMIT)
     // dkm : force gcvSURF_TILE_STATUS use contiguous memory
-    if(gcvSURF_TILE_STATUS == Type)     pool = gcvPOOL_CONTIGUOUS;
+    //if(gcvSURF_TILE_STATUS == Type)     pool = gcvPOOL_CONTIGUOUS;
 #endif
 
     do
@@ -370,7 +369,9 @@ _AllocateMemory(
             pool = gcvPOOL_SYSTEM;
         }
         else
-        if (pool == gcvPOOL_SYSTEM)
+        if ((pool == gcvPOOL_SYSTEM)
+        &&  (Type != gcvSURF_TILE_STATUS)
+        )
         {
             /* Advance to contiguous memory. */
             pool = gcvPOOL_CONTIGUOUS;
@@ -404,7 +405,7 @@ _AllocateMemory(
         /* Return pool used for allocation. */
         *Pool = pool;
     } else {
-        printk("_AllocateMemory fail! pool=%d, Bytes=%d, Type=%d\n", pool, (int)Bytes, Type);
+        printk("_AllocateMemory fail! pool=%d->%d, Bytes=%d, Type=%d\n", *Pool, pool, (int)Bytes, Type);
     }
 
     /* Return status. */
@@ -468,6 +469,10 @@ gckKERNEL_Dispatch(
         gcmkONERROR(
             gckOS_GetBaseAddress(Kernel->os,
                                  &Interface->u.GetBaseAddress.baseAddress));
+        strcpy(Interface->u.GetBaseAddress.fwVersion, GPU_FW_VERSION);
+#if BUILD_FOR_1_28
+        strcat(Interface->u.GetBaseAddress.fwVersion, "_for1.28");
+#endif
         break;
 
     case gcvHAL_QUERY_VIDEO_MEMORY:
index 0e7be33b3b820a36e8fe02b4b8c3232585ac7475..007fe56ad5710f0d313f0ea5e4165b335c87b0c5 100644 (file)
@@ -822,6 +822,7 @@ gckVIDMEM_AllocateLinear(
 
     acquired = gcvTRUE;
 
+#if 0
     // dkm: ¶ÔÓÚ»¨ÆÁËÀ»úµÄÎÊÌ⣬¸Ð¾õVVÕâô×öÖ»Êǹæ±Ü£¬»¹ÊÇûÓÐÕÒµ½ÎÊÌâµÄÔ­Òò
        if (Type == gcvSURF_TILE_STATUS
     && (Bytes + (1 << 20) > Memory->freeBytes)
@@ -830,6 +831,16 @@ gckVIDMEM_AllocateLinear(
         /* Not enough memory. */
         gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
        }
+#else
+    // dkm : ÎªgcvSURF_TILE_STATUS±£Áô2MµÄ¿Õ¼ä
+       if (Type != gcvSURF_TILE_STATUS
+    && (Bytes + (2 << 20) > Memory->freeBytes)
+       )
+    {
+        /* Not enough memory. */
+        gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
+       }
+#endif
 
     // dkm: ¶àÔ¤Áô64KµÄ¿Õ¼ä£¬·ñÔòGPU»áÓзÃÎÊ·Ç·¨µØÖ·µÄ·çÏÕ
     if (Bytes + (64 << 10) > Memory->freeBytes)
old mode 100755 (executable)
new mode 100644 (file)
index 5a51e12..3e4518b
@@ -344,6 +344,9 @@ int drv_release(struct inode* inode, struct file* filp)
 
 #ifndef ANDROID
        gcmkVERIFY_OK(gckCOMMAND_Stall(device->kernel->command));
+#else
+    // dkm: ±£ÁôdelayµÄ×ö·¨
+    //gcmkVERIFY_OK(gckOS_Delay(galDevice->os, 1000));
 #endif
 
     gcmkVERIFY_OK(
@@ -352,10 +355,7 @@ int drv_release(struct inode* inode, struct file* filp)
 #if gcdkUSE_MEMORY_RECORD
        FreeAllMemoryRecord(galDevice->os, private, &private->memoryRecordList);
 
-#ifdef ANDROID
-// dkm: ±£ÁôdelayµÄ×ö·¨
-       gcmkVERIFY_OK(gckOS_Delay(galDevice->os, 1000));
-#else
+#ifndef ANDROID
        gcmkVERIFY_OK(gckCOMMAND_Stall(device->kernel->command));
 #endif
 #endif
old mode 100755 (executable)
new mode 100644 (file)
index 2581c26..dee7ef6
@@ -30,7 +30,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <asm/atomic.h>
-#ifdef NO_DMA_COHERENT
+#if USE_DMA_COHERENT
 #include <linux/dma-mapping.h>
 #endif /* NO_DMA_COHERENT */
 
@@ -38,7 +38,6 @@
 #include <linux/delay.h>
 #include <mach/pmu.h>
 #include <mach/cru.h>
-#define IOREMAP_IN_NOPAGE           0
 
 #if !USE_NEW_LINUX_SIGNAL
 #define USER_SIGNAL_TABLE_LEN_INIT  64
@@ -146,7 +145,12 @@ struct _gckOS
     gcsMapedNonPagedCache *     cacheTail;
 
     gctINT                      pageNum;
-    struct page *               pageCache[100];
+    #if USE_DMA_COHERENT
+        gctSTRING               addr[100];
+        dma_addr_t              dmaHandle[100];
+    #else
+        struct page *           pageCache[100];
+    #endif
 #endif
 };
 
@@ -532,9 +536,17 @@ gckOS_Construct(
 
 #if gcdkUSE_MAPED_NONPAGE_CACHE
     for(os->pageNum=0; os->pageNum<50; os->pageNum++) {
+    #if USE_DMA_COHERENT
+        os->addr[os->pageNum] = 
+        #if (2==gcdENABLE_MEM_CACHE)
+            dma_alloc_writecombine(NULL, 5 * PAGE_SIZE, &os->dmaHandle[os->pageNum], GFP_ATOMIC);
+        #else
+            dma_alloc_coherent(NULL, 5 * PAGE_SIZE, &os->dmaHandle[os->pageNum], GFP_ATOMIC);
+        #endif
+    #else
         os->pageCache[os->pageNum] = alloc_pages(GFP_KERNEL | GFP_DMA, get_order(5 * PAGE_SIZE));
+    #endif
     }
-    //printk("os->pageNum = %d\n", os->pageNum);
 #endif
 
     /* Return pointer to the gckOS object. */
@@ -614,9 +626,11 @@ gckOS_Destroy(
     _FreeAllMapedNonPagedCache(Os, 0);
 
     for(i=0; i<Os->pageNum; i++) {
-        if(Os->pageCache[i]) {
-            free_pages((unsigned long)page_address(Os->pageCache[i]), get_order(5 * PAGE_SIZE));
-        }
+    #if USE_DMA_COHERENT
+        if(Os->addr[i])    dma_free_coherent(gcvNULL, 5 * PAGE_SIZE, Os->addr[i], Os->dmaHandle[i]);
+    #else
+        if(Os->pageCache[i])    free_pages((unsigned long)page_address(Os->pageCache[i]), get_order(5 * PAGE_SIZE));
+    #endif
     }
 #endif
 
@@ -1071,8 +1085,12 @@ gckOS_MapMemory(
             return gcvSTATUS_OUT_OF_RESOURCES;
         }
 
-#ifndef NO_DMA_COHERENT
+#if USE_DMA_COHERENT
+    #if (2==gcdENABLE_MEM_CACHE)
+        if (dma_mmap_writecombine(NULL,
+    #else
         if (dma_mmap_coherent(NULL,
+    #endif
                     mdlMap->vma,
                     mdl->addr,
                     mdl->dmaHandle,
@@ -1447,11 +1465,9 @@ gckOS_AllocateNonPagedMemory(
     gctINT          numPages;
     PLINUX_MDL      mdl;
     PLINUX_MDL_MAP  mdlMap = 0;
-#if IOREMAP_IN_NOPAGE
     gctSTRING       addr;
-#endif
 
-#ifdef NO_DMA_COHERENT
+#if !USE_DMA_COHERENT
     struct page *   page;
     long            size, order;
     gctPOINTER      vaddr, reserved_vaddr;
@@ -1507,11 +1523,34 @@ gckOS_AllocateNonPagedMemory(
 
     MEMORY_LOCK(Os);
 
-#ifndef NO_DMA_COHERENT
-    addr = dma_alloc_coherent(NULL,
-                mdl->numPages * PAGE_SIZE,
-                &mdl->dmaHandle,
-                GFP_ATOMIC);
+#if USE_DMA_COHERENT
+    #if gcdkUSE_MAPED_NONPAGE_CACHE
+        if(5==mdl->numPages && Os->pageNum>0 && Os->addr[Os->pageNum-1]) {
+            Os->pageNum--;
+            addr = Os->addr[Os->pageNum];
+            mdl->dmaHandle = Os->dmaHandle[Os->pageNum];
+            Os->addr[Os->pageNum] = gcvNULL;
+            Os->dmaHandle[Os->pageNum] = 0;
+        } else {
+        #if (2==gcdENABLE_MEM_CACHE)
+            addr = dma_alloc_writecombine(NULL,
+        #else
+            addr = dma_alloc_coherent(NULL,
+        #endif
+                        mdl->numPages * PAGE_SIZE,
+                        &mdl->dmaHandle,
+                        GFP_ATOMIC);
+        }
+    #else
+        #if (2==gcdENABLE_MEM_CACHE)
+            addr = dma_alloc_writecombine(NULL,
+        #else
+            addr = dma_alloc_coherent(NULL,
+        #endif
+                        mdl->numPages * PAGE_SIZE,
+                        &mdl->dmaHandle,
+                        GFP_ATOMIC);
+    #endif
 #else
     size    = mdl->numPages * PAGE_SIZE;
     order   = get_order(size);
@@ -1556,15 +1595,14 @@ gckOS_AllocateNonPagedMemory(
         reserved_size  -= PAGE_SIZE;
     }
 
-#if IOREMAP_IN_NOPAGE
-    // dkm: gcdENABLE_MEM_CACHE
-    #if (1==gcdENABLE_MEM_CACHE)
-        addr            = ioremap_cached(virt_to_phys(vaddr), size);
-    #else
-        addr            = ioremap_nocache(virt_to_phys(vaddr), size);
-    #endif
+// dkm: gcdENABLE_MEM_CACHE
+#if (1==gcdENABLE_MEM_CACHE)
+    addr            = ioremap_cached(virt_to_phys(vaddr), size);
+#else
+    addr            = ioremap_nocache(virt_to_phys(vaddr), size);
 #endif
 
+
     mdl->dmaHandle  = virt_to_phys(vaddr);
     mdl->kaddr      = vaddr;
 
@@ -1574,7 +1612,6 @@ gckOS_AllocateNonPagedMemory(
 
 #endif
 
-#if IOREMAP_IN_NOPAGE
     if (addr == gcvNULL)
     {
         gcmkTRACE_ZONE(gcvLEVEL_INFO,
@@ -1588,7 +1625,6 @@ gckOS_AllocateNonPagedMemory(
 
         return gcvSTATUS_OUT_OF_MEMORY;
     }
-#endif
 
     if ((Os->baseAddress & 0x80000000) != (mdl->dmaHandle & 0x80000000))
     {
@@ -1596,11 +1632,7 @@ gckOS_AllocateNonPagedMemory(
                        | (Os->baseAddress & 0x80000000);
     }
 
-#if IOREMAP_IN_NOPAGE
     mdl->addr = addr;
-#else
-    mdl->addr = vaddr;
-#endif
 
     /*
      * We will not do any mapping from here.
@@ -1671,8 +1703,12 @@ gckOS_AllocateNonPagedMemory(
             return gcvSTATUS_OUT_OF_RESOURCES;
         }
 
-#ifndef NO_DMA_COHERENT
+#if USE_DMA_COHERENT
+    #if (2==gcdENABLE_MEM_CACHE)
+        if (dma_mmap_writecombine(NULL,
+    #else
         if (dma_mmap_coherent(NULL,
+    #endif
                 mdlMap->vma,
                 mdl->addr,
                 mdl->dmaHandle,
@@ -1836,7 +1872,7 @@ gceSTATUS gckOS_FreeNonPagedMemoryRealy(
     // dkm: add
     struct mm_struct *      mm;
 
-#ifdef NO_DMA_COHERENT
+#if !USE_DMA_COHERENT
     unsigned                size;
     gctPOINTER              vaddr;
 #endif /* NO_DMA_COHERENT */
@@ -1856,11 +1892,24 @@ gceSTATUS gckOS_FreeNonPagedMemoryRealy(
 
     if(MemLock)     MEMORY_LOCK(Os);
 
-#ifndef NO_DMA_COHERENT
-    dma_free_coherent(gcvNULL,
-                    mdl->numPages * PAGE_SIZE,
-                    mdl->addr,
-                    mdl->dmaHandle);
+#if USE_DMA_COHERENT
+    #if gcdkUSE_MAPED_NONPAGE_CACHE
+        if(5==mdl->numPages && Os->pageNum<100 && !Os->addr[Os->pageNum]) {
+            Os->addr[Os->pageNum] = mdl->addr;
+            Os->dmaHandle[Os->pageNum] = mdl->dmaHandle;
+            Os->pageNum ++;
+        } else {
+            dma_free_coherent(gcvNULL,
+                            mdl->numPages * PAGE_SIZE,
+                            mdl->addr,
+                            mdl->dmaHandle);
+        }
+    #else
+        dma_free_coherent(gcvNULL,
+                        mdl->numPages * PAGE_SIZE,
+                        mdl->addr,
+                        mdl->dmaHandle);
+    #endif
 #else
     size    = mdl->numPages * PAGE_SIZE;
     vaddr   = mdl->kaddr;
@@ -1885,9 +1934,7 @@ gceSTATUS gckOS_FreeNonPagedMemoryRealy(
     free_pages((unsigned long)mdl->kaddr, get_order(mdl->numPages * PAGE_SIZE));
 #endif
 
-#if IOREMAP_IN_NOPAGE
     iounmap(mdl->addr);
-#endif
 #endif /* NO_DMA_COHERENT */
 
     mdlMap = mdl->maps;
index 9b07470c5f9f608c89308319dcf2c1c954bc2f3e..576bf90ba7732fe1f85fd0cf02564b88474ae33a 100755 (executable)
@@ -2888,11 +2888,17 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
                udev->ttport = hdev->ttport;
        } else if (udev->speed != USB_SPEED_HIGH
                        && hdev->speed == USB_SPEED_HIGH) {
+                       
+       /* yk@rk 20110617
+        * parent hub has no TT would not be error in rk29
+        */
+               #if 0
                if (!hub->tt.hub) {
                        dev_err(&udev->dev, "parent hub has no TT\n");
                        retval = -EINVAL;
                        goto fail;
                }
+               #endif
                udev->tt = &hub->tt;
                udev->ttport = port1;
        }
index 316387d5491fd189dc7ba1afdff4894a5d4db5cd..d0fdfbd44dae0942732b9128ca7fe5a85104ef8a 100755 (executable)
@@ -2420,6 +2420,7 @@ void dwc_otg_ep0_start_transfer(dwc_otg_core_if_t *_core_if, dwc_ep_t *_ep)
                {       
                        dwc_write_reg32 (&(in_regs->diepdma), 
                                (uint32_t)_ep->dma_addr);
+                   _ep->dma_addr += _ep->xfer_len;
                }
        
                /* EP enable, IN data in FIFO */
index 21e341f964fbf2a4e52e2e92b3f37fb6d6ebe7ef..8a1665a001d1b29790e34a67c3c576371b2d215f 100755 (executable)
@@ -519,6 +519,12 @@ int32_t dwc_otg_hcd_handle_hc_intr (dwc_otg_hcd_t *_dwc_otg_hcd)
                        retval |= dwc_otg_hcd_handle_hc_n_intr (_dwc_otg_hcd, hcnum);
                }
        }
+       haint.d32 = dwc_otg_read_host_all_channels_intr(_dwc_otg_hcd->core_if);
+       int i;
+       for (i = 0; i < _dwc_otg_hcd->core_if->core_params->host_channels; i++) {
+               if (haint.b2.chint & (1 << i))
+                       retval |= dwc_otg_hcd_handle_hc_n_intr(_dwc_otg_hcd, i);
+       }
 #endif
        return retval;
 }
index 342c6eae7c08213858299b676eca150f7bf8c965..0853ff83a23600218208e5e821b25c188cf32e7b 100755 (executable)
@@ -76,7 +76,7 @@ static int rk29_button_light_probe(struct platform_device *pdev)
 {               
     struct rk29_button_light_info *button_light_info = pdev->dev.platform_data;
     
-       rk29_button_light_device = backlight_device_register("rk28_button_light", &pdev->dev, NULL, &rk29_button_light_ops);
+       rk29_button_light_device = backlight_device_register("rk28_button_light", &pdev->dev, NULL, &rk29_button_light_ops,NULL);
        if (!rk29_button_light_device) {
         DBG("rk29_button_light_probe error\n"); 
                return -ENODEV;         
index d972c75ab89de6fd63f7b4f0451cf464f79b8077..2ec2120c26b908718ebbdc3128b20c630966d6d7 100755 (executable)
@@ -29,6 +29,8 @@ config LCD_RGB_TFT480800_25_E
          bool "RGB TFT480800_25_E(480X800)"
 config LCD_LS035Y8DX02A
          bool "RGB LS035Y8DX02A(480X800)"
+config LCD_LS035Y8DX04A
+         bool "RGB LS035Y8DX04A(480X800)"
 config LCD_CPTCLAA038LA31XE
          bool "RGB LCD_CPTCLAA038LA31XE(480X800)"        
 config LCD_A060SE02
index 0ad22f5d5d7ec2ef79569a0b7a9477a053f3b624..0abb52a1214b2d0c692cc01595acb31582c9e452 100755 (executable)
@@ -16,6 +16,7 @@ obj-$(CONFIG_LCD_IPS1P5680_V1_E) += lcd_ips1p5680_v1_e.o
 obj-$(CONFIG_LCD_RGB_TFT480800_25_E) += lcd_rgb_tft480800_25_e.o
 obj-$(CONFIG_LCD_MCU_TFT480800_25_E) += lcd_mcu_tft480800_25_e.o
 obj-$(CONFIG_LCD_LS035Y8DX02A) += lcd_ls035y8dx02a.o
+obj-$(CONFIG_LCD_LS035Y8DX04A) += lcd_ls035y8dx04a.o
 obj-$(CONFIG_LCD_CPTCLAA038LA31XE) += lcd_CPTclaa038la31xe.o
 
 
@@ -31,4 +32,4 @@ obj-$(CONFIG_LCD_IPS1P5680_V1_E) += lcd_ips1p5680_v1_e.o
 obj-$(CONFIG_LCD_MCU_TFT480800_25_E) += lcd_mcu_tft480800_25_e.o
 obj-$(CONFIG_LCD_AT070TNA2)    += lcd_AT070TNA2.o
 obj-$(CONFIG_LCD_TX23D88VM) += lcd_tx23d88vm.o
-obj-$(CONFIG_LCD_AT070TN93)    += lcd_at070tn93.o
\ No newline at end of file
+obj-$(CONFIG_LCD_AT070TN93)    += lcd_at070tn93.o
diff --git a/drivers/video/display/screen/lcd_ls035y8dx04a.c b/drivers/video/display/screen/lcd_ls035y8dx04a.c
new file mode 100644 (file)
index 0000000..f175729
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 2011 ROCKCHIP, Inc.
+ *
+ * author: hhb@rock-chips.com
+ * creat date: 2011-03-22
+ * route:drivers/video/display/screen/lcd_ls035y8dx02a.c - driver for rk29 phone sdk
+ * declaration: This program driver have been tested in rk29_phonesdk hardware platform at 2011.03.31.
+ * about migration: you need just 3 interface functions,such as lcd_init(void),lcd_standby(u8 enable),
+ * set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+
+#include <linux/fb.h>
+#include <linux/delay.h>
+#include "../../rk29_fb.h"
+#include <mach/gpio.h>
+#include <mach/iomux.h>
+#include <mach/board.h>
+#include "screen.h"
+
+/* Base */
+#define OUT_TYPE               SCREEN_RGB
+#define OUT_FACE               OUT_P888
+#define OUT_CLK                        (26*1000000)    //***27  uint Hz
+#define LCDC_ACLK       150000000     //29 lcdc axi DMA Ƶ��
+
+/* Timing */
+#define H_PW                   8 //16
+#define H_BP                   6//24
+#define H_VD                   480//320
+#define H_FP                   60//16
+
+#define V_PW                   2
+#define V_BP                   2
+#define V_VD                   800//480
+#define V_FP                   4
+
+#define LCD_WIDTH       46    //need modify
+#define LCD_HEIGHT      76
+
+/* Other */
+#define DCLK_POL               1             //0 
+#define SWAP_RB                        0
+
+static struct rk29lcd_info *gLcd_info = NULL;
+int lcd_init(void);
+int lcd_standby(u8 enable);
+
+#define RXD_PORT        RK29_PIN2_PC7
+#define TXD_PORT        gLcd_info->txd_pin
+#define CLK_PORT        gLcd_info->clk_pin
+#define CS_PORT         gLcd_info->cs_pin
+#define RESET_PORT      RK29_PIN6_PC6
+
+#define CS_OUT()        gpio_direction_output(CS_PORT, 1)
+#define CS_SET()        gpio_set_value(CS_PORT, GPIO_HIGH)
+#define CS_CLR()        gpio_set_value(CS_PORT, GPIO_LOW)
+#define CLK_OUT()       gpio_direction_output(CLK_PORT, 0) 
+#define CLK_SET()       gpio_set_value(CLK_PORT, GPIO_HIGH)
+#define CLK_CLR()       gpio_set_value(CLK_PORT, GPIO_LOW)
+#define TXD_OUT()       gpio_direction_output(TXD_PORT, 1)   
+#define TXD_SET()       gpio_set_value(TXD_PORT, GPIO_HIGH)
+#define TXD_CLR()       gpio_set_value(TXD_PORT, GPIO_LOW)
+#define RXD_IN()        gpio_direction_input(RXD_PORT)
+#define RXD_GET()          gpio_get_value(RXD_PORT)
+
+#define DRVDelayUs(i)   udelay(i*4)
+
+u32 spi_screenreg_get(u32 Addr)
+{
+    u32 i, data = 0;
+    u32 control_bit;
+
+    TXD_OUT();
+    CLK_OUT();
+    CS_OUT();
+    DRVDelayUs(2);
+    DRVDelayUs(2);
+
+    CS_SET();
+    TXD_SET();
+    CLK_CLR();
+    DRVDelayUs(30);
+
+        CS_CLR();
+        control_bit = 0x0000;
+        Addr = (control_bit | Addr);
+        printk("addr is 0x%x \n", Addr); 
+        for(i = 0; i < 9; i++)  //reg
+        {
+                       if(Addr &(1<<(8-i)))
+                                       TXD_SET();
+                       else
+                                       TXD_CLR();
+
+                       // \u6a21\u62dfCLK
+                       CLK_SET();
+                       DRVDelayUs(2);
+                       CLK_CLR();
+                       DRVDelayUs(2);
+        }
+
+        CS_SET();
+        TXD_SET();
+        CLK_CLR();             
+        DRVDelayUs(10);
+               
+        CS_CLR();      
+        for(i = 0; i < 9; i++)
+        {
+                       CLK_SET();
+                       DRVDelayUs(2);
+                       CLK_CLR();
+                       if(RXD_GET())
+                       {
+                               data |= 1<<(8-i);
+                       }
+                       else
+                       {
+                               data &= ~(1<<(8-i));
+                       }
+                       DRVDelayUs(2);
+        }
+        CS_SET();
+        CLK_CLR();
+        TXD_CLR();
+        DRVDelayUs(30);
+        
+       return data;
+}
+
+void spi_screenreg_set(u32 Addr, u32 Data0, u32 Data1)
+{
+
+
+    u32 i;
+    u32 control_bit;
+
+    TXD_OUT();
+    CLK_OUT();
+    CS_OUT();
+    DRVDelayUs(2);
+    DRVDelayUs(2);
+
+    CS_SET();
+    TXD_SET();
+    CLK_CLR();
+    DRVDelayUs(30);
+
+        CS_CLR();
+        control_bit = 0x0000;
+        Addr = (control_bit | Addr);
+        //printk("addr is 0x%x \n", Addr); 
+        for(i = 0; i < 9; i++)  //reg
+        {
+                       if(Addr &(1<<(8-i)))
+                                       TXD_SET();
+                       else
+                                       TXD_CLR();
+                       CLK_SET();
+                       DRVDelayUs(2);
+                       CLK_CLR();
+                       DRVDelayUs(2);
+        }
+
+        CS_SET();
+        TXD_SET();
+        CLK_CLR();             
+        DRVDelayUs(10);
+
+        if(0xffff == Data0){
+                return;
+        }
+               
+        CS_CLR();
+        control_bit = 0x0100;
+        Data0 = (control_bit | Data0);
+        //printk("data0 is 0x%x \n", Data); 
+        for(i = 0; i < 9; i++)  //data
+        {
+                       if(Data0 &(1<<(8-i)))
+                                       TXD_SET();
+                       else
+                                       TXD_CLR();
+                       CLK_SET();
+                       DRVDelayUs(2);
+                       CLK_CLR();
+                       DRVDelayUs(2);
+        }
+
+        CS_SET();
+        CLK_CLR();
+        TXD_CLR();
+        DRVDelayUs(10);
+
+        if(0xffff == Data1)
+               return;
+               
+        CS_CLR();
+        control_bit = 0x0100;
+        Data1 = (control_bit | Data1);
+        //printk("data1 is 0x%x \n", Data); 
+        for(i = 0; i < 9; i++)  //data
+        {
+                       if(Data1 &(1<<(8-i)))
+                                       TXD_SET();
+                       else
+                                       TXD_CLR();
+                       CLK_SET();
+                       DRVDelayUs(2);
+                       CLK_CLR();
+                       DRVDelayUs(2);
+        }
+
+        CS_SET();
+        CLK_CLR();
+        TXD_CLR();
+        DRVDelayUs(30);
+}
+
+void set_lcd_info(struct rk29fb_screen *screen, struct rk29lcd_info *lcd_info )
+{
+    /* screen type & face */
+    screen->type = OUT_TYPE;
+    screen->face = OUT_FACE;
+    /* Screen size */
+    screen->x_res = H_VD;
+    screen->y_res = V_VD;
+    screen->width = LCD_WIDTH;
+    screen->height = LCD_HEIGHT;
+
+    /* Timing */
+    screen->lcdc_aclk = LCDC_ACLK;
+    screen->pixclock = OUT_CLK;
+       screen->left_margin = H_BP;             /*>2*/ 
+       screen->right_margin = H_FP;    /*>2*/ 
+       screen->hsync_len = H_PW;               /*>2*/ //***all > 326, 4<PW+BP<15, 
+       screen->upper_margin = V_BP;    /*>2*/ 
+       screen->lower_margin = V_FP;    /*>2*/ 
+       screen->vsync_len = V_PW;               /*>6*/ 
+
+       /* Pin polarity */
+       screen->pin_hsync = 0; 
+       screen->pin_vsync = 0; 
+       screen->pin_den = 0;
+       screen->pin_dclk = DCLK_POL;
+
+       /* Swap rule */
+    screen->swap_rb = SWAP_RB;
+    screen->swap_rg = 0;
+    screen->swap_gb = 0;
+    screen->swap_delta = 0;
+    screen->swap_dumy = 0;
+
+    /* Operation function*/
+    screen->init = lcd_init;
+    screen->standby = lcd_standby;
+    if(lcd_info)
+        gLcd_info = lcd_info;
+}
+
+int lcd_init(void)
+{ 
+       volatile u32 data;
+    if(gLcd_info){
+        gLcd_info->io_init();
+       }
+
+    /* reset lcd to start init lcd by software if there is no hardware reset circuit for the lcd */
+#ifdef RESET_PORT
+    gpio_request(RESET_PORT, NULL);
+    gpio_direction_output(RESET_PORT, 0);
+    mdelay(2);
+    gpio_set_value(RESET_PORT, 1);
+    mdelay(10);
+    gpio_free(RESET_PORT);
+#endif
+
+       printk("lcd init...\n");
+       spi_screenreg_set(0x29, 0xffff, 0xffff);      //display on
+       spi_screenreg_set(0x11, 0xffff, 0xffff);      //sleep out
+       mdelay(150);
+       spi_screenreg_set(0x36, 0x0000, 0xffff);      //set address mode
+       
+       while(0)  //this code is not used here
+       {       
+               data = spi_screenreg_get(0x0a); 
+               printk("------------liuylcd init reg 0x0a=0x%x \n", spi_screenreg_get(0x0a));
+               data = spi_screenreg_get(0x0b);
+               printk("------------liuylcd init reg 0x0b=0x%x \n", spi_screenreg_get(0x0b));
+               data = spi_screenreg_get(0x0c);
+               printk("------------liuylcd init reg 0x0c=0x%x \n", spi_screenreg_get(0x0c));
+               data = spi_screenreg_get(0x0d);
+               printk("------------liuylcd init reg 0x0d=0x%x \n", spi_screenreg_get(0x0d));
+               data = spi_screenreg_get(0x0f);
+               printk("------------liuylcd init reg 0x0f=0x%x \n", spi_screenreg_get(0x0f));
+       }       
+
+       spi_screenreg_set(0x3a, 0x0070, 0xffff);      //set pixel format
+       spi_screenreg_set(0xb0, 0x0000, 0xffff);      //enable command acess
+       spi_screenreg_set(0xb8, 0x0000, 0xffff);      //BLC setting
+       spi_screenreg_set(0xb9, 0x0001, 0x00ff);      //LED PWM
+       //spi_screenreg_set(0xb0, 0x0003, 0xffff);      //disable command acess
+       
+    if(gLcd_info)
+        gLcd_info->io_deinit();
+
+    return 0;
+}
+
+extern void rk29_lcd_spim_spin_lock(void);
+extern void rk29_lcd_spim_spin_unlock(void);
+int lcd_standby(u8 enable)     //***enable =1 means suspend, 0 means resume 
+{
+       rk29_lcd_spim_spin_lock();
+       if(gLcd_info)
+       gLcd_info->io_init();
+       printk("lcd standby\n");
+       if(enable) {
+               printk("lcd standby...enable =1 means suspend\n");
+               spi_screenreg_set(0x10, 0xffff, 0xffff);
+               mdelay(120);
+               spi_screenreg_set(0x28, 0xffff, 0xffff);
+       } else { 
+               printk("lcd standby...0 means resume\n");
+               spi_screenreg_set(0x29, 0xffff, 0xffff);
+               spi_screenreg_set(0x11, 0xffff, 0xffff);
+               //mdelay(150);
+       }
+
+    if(gLcd_info)
+       gLcd_info->io_deinit();
+       rk29_lcd_spim_spin_unlock();
+    return 0;
+}
+
index 49c824899e5e9b56cd7618def1d98656e4bad8ee..e0360ceb7fd6a025acc72b5037a7d6178411cd59 100755 (executable)
@@ -1,5 +1,5 @@
 #include <linux/hdmi.h>
-#if defined CONFIG_SND_SOC_WM8900 || defined CONFIG_SND_SOC_RT5631
+#if defined CONFIG_SND_SOC_WM8900 || defined CONFIG_SND_SOC_RT5631 || defined CONFIG_SND_SOC_RT5621
 /* sound/soc/codecs/wm8900.c */
 extern void codec_set_spk(bool on);
 #else
index 7929fc9d67091c6e2502b9caaf584b35a545943f..f0b69cdae41cc94f24c995d9812301d9eb711451 100644 (file)
@@ -15,7 +15,6 @@
 #ifndef __MFD_WM8994_CORE_H__
 #define __MFD_WM8994_CORE_H__
 
-<<<<<<< HEAD
 #include <linux/interrupt.h>
 
 enum wm8994_type {
@@ -23,16 +22,36 @@ enum wm8994_type {
        WM8958 = 1,
 };
 
-=======
->>>>>>> parent of 15f7fab... temp revert rk change
 struct regulator_dev;
 struct regulator_bulk_data;
 
 #define WM8994_NUM_GPIO_REGS 11
-#define WM8994_NUM_LDO_REGS 2
+#define WM8994_NUM_LDO_REGS   2
+#define WM8994_NUM_IRQ_REGS   2
+
+#define WM8994_IRQ_TEMP_SHUT           0
+#define WM8994_IRQ_MIC1_DET            1
+#define WM8994_IRQ_MIC1_SHRT           2
+#define WM8994_IRQ_MIC2_DET            3
+#define WM8994_IRQ_MIC2_SHRT           4
+#define WM8994_IRQ_FLL1_LOCK           5
+#define WM8994_IRQ_FLL2_LOCK           6
+#define WM8994_IRQ_SRC1_LOCK           7
+#define WM8994_IRQ_SRC2_LOCK           8
+#define WM8994_IRQ_AIF1DRC1_SIG_DET    9
+#define WM8994_IRQ_AIF1DRC2_SIG_DET    10
+#define WM8994_IRQ_AIF2DRC_SIG_DET     11
+#define WM8994_IRQ_FIFOS_ERR           12
+#define WM8994_IRQ_WSEQ_DONE           13
+#define WM8994_IRQ_DCS_DONE            14
+#define WM8994_IRQ_TEMP_WARN           15
+
+/* GPIOs in the chip are numbered from 1-11 */
+#define WM8994_IRQ_GPIO(x) (x + WM8994_IRQ_TEMP_WARN)
 
 struct wm8994 {
        struct mutex io_lock;
+       struct mutex irq_lock;
 
        enum wm8994_type type;
 
@@ -45,6 +64,11 @@ struct wm8994 {
        void *control_data;
 
        int gpio_base;
+       int irq_base;
+
+       int irq;
+       u16 irq_masks_cur[WM8994_NUM_IRQ_REGS];
+       u16 irq_masks_cache[WM8994_NUM_IRQ_REGS];
 
        /* Used over suspend/resume */
        bool suspended;
@@ -67,4 +91,26 @@ int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
 int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
                     int count, const u16 *buf);
 
+
+/* Helper to save on boilerplate */
+static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq,
+                                    irq_handler_t handler, const char *name,
+                                    void *data)
+{
+       if (!wm8994->irq_base)
+               return -EINVAL;
+       return request_threaded_irq(wm8994->irq_base + irq, NULL, handler,
+                                   IRQF_TRIGGER_RISING, name,
+                                   data);
+}
+static inline void wm8994_free_irq(struct wm8994 *wm8994, int irq, void *data)
+{
+       if (!wm8994->irq_base)
+               return;
+       free_irq(wm8994->irq_base + irq, data);
+}
+
+int wm8994_irq_init(struct wm8994 *wm8994);
+void wm8994_irq_exit(struct wm8994 *wm8994);
+
 #endif
index f63b990b366e77a3a2ee87a89d4de34b6314d432..97cf4f27d6470120a389bb8a2e1217871b8e3411 100755 (executable)
@@ -26,10 +26,16 @@ struct wm8994_ldo_pdata {
        struct regulator_init_data *init_data;
 };
 
-#define WM8994_CONFIGURE_GPIO 0x8000
+#define WM8994_CONFIGURE_GPIO 0x10000
 
 #define WM8994_DRC_REGS 5
-#define WM8994_EQ_REGS  19
+#define WM8994_EQ_REGS  20
+#define WM8958_MBC_CUTOFF_REGS 20
+#define WM8958_MBC_COEFF_REGS  48
+#define WM8958_MBC_COMBINED_REGS 56
+#define WM8958_VSS_HPF_REGS 2
+#define WM8958_VSS_REGS 148
+#define WM8958_ENH_EQ_REGS 32
 
 /**
  * DRC configurations are specified with a label and a set of register
@@ -59,8 +65,53 @@ struct wm8994_retune_mobile_cfg {
         u16 regs[WM8994_EQ_REGS];
 };
 
-#define PCM_BB 1
-#define NO_PCM_BB 0
+/**
+ * Multiband compressor configurations are specified with a label and
+ * two sets of values to write.  Configurations are expected to be
+ * generated using the multiband compressor configuration panel in
+ * WISCE - see http://www.wolfsonmicro.com/wisce/
+ */
+struct wm8958_mbc_cfg {
+       const char *name;
+       u16 cutoff_regs[WM8958_MBC_CUTOFF_REGS];
+       u16 coeff_regs[WM8958_MBC_COEFF_REGS];
+
+       /* Coefficient layout when using MBC+VSS firmware */
+       u16 combined_regs[WM8958_MBC_COMBINED_REGS];
+};
+
+/**
+ * VSS HPF configurations are specified with a label and two values to
+ * write.  Configurations are expected to be generated using the
+ * multiband compressor configuration panel in WISCE - see
+ * http://www.wolfsonmicro.com/wisce/
+ */
+struct wm8958_vss_hpf_cfg {
+       const char *name;
+       u16 regs[WM8958_VSS_HPF_REGS];
+};
+
+/**
+ * VSS configurations are specified with a label and array of values
+ * to write.  Configurations are expected to be generated using the
+ * multiband compressor configuration panel in WISCE - see
+ * http://www.wolfsonmicro.com/wisce/
+ */
+struct wm8958_vss_cfg {
+       const char *name;
+       u16 regs[WM8958_VSS_REGS];
+};
+
+/**
+ * Enhanced EQ configurations are specified with a label and array of
+ * values to write.  Configurations are expected to be generated using
+ * the multiband compressor configuration panel in WISCE - see
+ * http://www.wolfsonmicro.com/wisce/
+ */
+struct wm8958_enh_eq_cfg {
+       const char *name;
+       u16 regs[WM8958_ENH_EQ_REGS];
+};
 
 struct wm8994_pdata {
        int gpio_base;
@@ -73,6 +124,7 @@ struct wm8994_pdata {
 
        struct wm8994_ldo_pdata ldo[WM8994_NUM_LDO];
 
+       int irq_base;  /** Base IRQ number for WM8994, required for IRQs */
 
         int num_drc_cfgs;
         struct wm8994_drc_cfg *drc_cfgs;
@@ -80,6 +132,18 @@ struct wm8994_pdata {
         int num_retune_mobile_cfgs;
         struct wm8994_retune_mobile_cfg *retune_mobile_cfgs;
 
+       int num_mbc_cfgs;
+       struct wm8958_mbc_cfg *mbc_cfgs;
+
+       int num_vss_cfgs;
+       struct wm8958_vss_cfg *vss_cfgs;
+
+       int num_vss_hpf_cfgs;
+       struct wm8958_vss_hpf_cfg *vss_hpf_cfgs;
+
+       int num_enh_eq_cfgs;
+       struct wm8958_enh_eq_cfg *enh_eq_cfgs;
+
         /* LINEOUT can be differential or single ended */
         unsigned int lineout1_diff:1;
         unsigned int lineout2_diff:1;
@@ -88,42 +152,21 @@ struct wm8994_pdata {
         unsigned int lineout1fb:1;
         unsigned int lineout2fb:1;
 
-        /* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
+       /* IRQ for microphone detection if brought out directly as a
+        * signal.
+        */
+       int micdet_irq;
+
+        /* WM8994 microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
         unsigned int micbias1_lvl:1;
         unsigned int micbias2_lvl:1;
 
-        /* Jack detect threashold levels, see datasheet for values */
+        /* WM8994 jack detect threashold levels, see datasheet for values */
         unsigned int jd_scthr:2;
         unsigned int jd_thr:2;
 
-               //for phonepad
-               unsigned int no_earpiece:1;      // =1  don't have a earpiece,  =0   has a earpiece
-               unsigned int sp_hp_same_channel:1;
-               
-               //BB input can be differential or single ended
-               unsigned int BB_input_diff:1;   //  =0  single ended     =1  differential
-               unsigned int BB_class:1;//PCM_BB= 1  NO_PCM_BB=0
-               
-               //If an external amplifier speakers wm8994              enable>0 disable=0
-               unsigned int PA_control_pin;
-
-               //wm8994 LDO1_ENA and LDO2_ENA
-               unsigned int Power_EN_Pin;
-               char    PowerEN_iomux_name[50];
-               int             PowerEN_iomux_mode;     
-
-       //volume
-       int speaker_incall_vol;                 //max = 6, min = -21
-       int speaker_incall_mic_vol;             //max = 30, min = -22
-       int speaker_normal_vol;                 //max = 6, min = -57
-       int earpiece_incall_vol;                //max = 6, min = -21
-       int headset_incall_vol;                 //max = 6, min = -12
-       int headset_incall_mic_vol;             //max = 30, min = -22
-       int headset_normal_vol;                 //max = 6, min = -57
-       int BT_incall_vol;                              //max = 30, min = -16
-       int BT_incall_mic_vol;                  //max = 6, min = -57
-       int recorder_vol;                               //max = 60 , min = -16
-               
+       /* WM8958 microphone bias configuration */
+       int micbias[2];
 };
 
 #endif
index 9c5f11a819d54bba93660e87afe55cb20b4fdb56..28facec4e825cc975401ec4272790abce3ef8745 100755 (executable)
@@ -11,6 +11,7 @@ struct modem_dev
 
 /* è\80³æ\9cºæ\95°æ\8d®ç»\93æ\9e\84ä½?*/
 struct rk2818_23d_data {
+       struct device *dev;
        int (*io_init)(void);
        int (*io_deinit)(void);
        unsigned int bp_power;
index e073695d44f550123d755ec10ae20012bb5597ec..86e14ef1898c26045b644d8307f2e70bc0f86781 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/syscalls.h> /* sys_sync */
 #include <linux/wakelock.h>
 #include <linux/workqueue.h>
-#include <linux/kallsyms.h>
 
 #include "power.h"
 
@@ -29,7 +28,7 @@ enum {
        DEBUG_SUSPEND = 1U << 2,
        DEBUG_VERBOSE = 1U << 3,
 };
-static int debug_mask = DEBUG_USER_STATE;
+static int debug_mask = DEBUG_USER_STATE | DEBUG_SUSPEND | DEBUG_VERBOSE;
 module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP);
 
 static DEFINE_MUTEX(early_suspend_lock);
@@ -99,8 +98,6 @@ static void early_suspend(struct work_struct *work)
                if (pos->suspend != NULL) {
                        if (debug_mask & DEBUG_VERBOSE)
                                pr_info("early_suspend: calling %pf\n", pos->suspend);
-                       if (debug_mask & DEBUG_VERBOSE)
-                               print_symbol("early_suspend: call %s\n", (unsigned long)pos->suspend);
                        pos->suspend(pos);
                }
        }
@@ -110,6 +107,8 @@ static void early_suspend(struct work_struct *work)
                pr_info("early_suspend: sync\n");
 
        sys_sync();
+       if (debug_mask & DEBUG_SUSPEND)
+               pr_info("early_suspend: done\n");
 abort:
        spin_lock_irqsave(&state_lock, irqflags);
        if (state == SUSPEND_REQUESTED_AND_SUSPENDED)
@@ -142,8 +141,6 @@ static void late_resume(struct work_struct *work)
                if (pos->resume != NULL) {
                        if (debug_mask & DEBUG_VERBOSE)
                                pr_info("late_resume: calling %pf\n", pos->resume);
-                       if (debug_mask & DEBUG_VERBOSE)
-                               print_symbol("late_resume: call %s\n", (unsigned long)pos->resume);
 
                        pos->resume(pos);
                }
index 6bb24bf0bd16df5ea82de773152156887f244cca..5c78d466a6b96a0da4b0705f0f0e18213e30cd41 100755 (executable)
@@ -8,7 +8,6 @@ arch/arm/mach-rk29/ddr.c
 arch/arm/mach-rk29/vpu*.c
 
 drivers/staging/rk29/ipp/rk29-ipp.c
-sound/soc/codecs/rt5625.c
 )
 
 DIRS=(
@@ -93,11 +92,6 @@ for d in ${DIRS[@]}; do
        [ -d $d ] && find $d -type f -name '*.uu' -print0 | xargs -0 rm -f
 done
 
-#zwp
-mv sound/soc/codecs/rt5625.c sound/soc/codecs/rt5625.c.bak
-mv sound/soc/codecs/rt5625.c.enc sound/soc/codecs/rt5625.c
-####
-
 echo build kernel on $kerndir with $defconfig
 make clean >/dev/null 2>&1
 make $defconfig >/dev/null 2>&1
@@ -119,15 +113,13 @@ for d in ${DIRS[@]}; do
        done
 done
 
-#zwp
-mv sound/soc/codecs/rt5625.c sound/soc/codecs/rt5625.c.enc
-mv sound/soc/codecs/rt5625.c.bak sound/soc/codecs/rt5625.c
-####
-
 make distclean >/dev/null 2>&1
 
 popd >/dev/null
 
+# fix local version
+echo "+" > $kerndir/.scmversion
+
 # tar kernel
 pushd $kerndir/../ >/dev/null
 package=$(basename $kerndir).tar
@@ -139,8 +131,6 @@ done
 for file in ${EXCLUDES[@]}; do
        echo "$file" >> $ex
 done
-echo sound/soc/codecs/rt5625.c >>$ex
-echo sound/soc/codecs/rt5625.c.enc >>$ex
 echo TAR $(pwd)/$package
 tar cf $package --numeric-owner --exclude-from $ex --exclude=.git --exclude=`basename $0` $(basename $kerndir)
 tar rf $package --numeric-owner --exclude=.git toolchain/arm-eabi-4.4.0
@@ -149,6 +139,8 @@ gzip -9 -c $package > $package.gz
 rm $ex
 popd >/dev/null
 
+rm -f $kerndir/.scmversion
+
 echo done
 
 
index 9f50f4f54a675f1c2a1bc83f13175d5848b39bdd..9dfeb311759f634520b068d5c444b24274219481 100644 (file)
@@ -74,7 +74,7 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI
        select SND_SOC_WM8804 if SND_SOC_I2C_AND_SPI
        select SND_SOC_WM8900 if I2C
-       select SND_SOC_alc5621 if I2C
+       select SND_SOC_RT5621 if I2C
        select SND_SOC_RT5631 if I2C
        select SND_SOC_RT5625 if I2C
        select SND_SOC_WM8903 if I2C
@@ -312,7 +312,7 @@ config SND_SOC_WM8804
 config SND_SOC_WM8900
        tristate
 
-config SND_SOC_alc5621
+config SND_SOC_RT5621
        tristate
 
 config SND_SOC_RT5631
index b4bf7e53b76b18c4dc14f3101cc88a8a00028ad6..b5c69a02e817578f477c5330314c1e2d1cd6c309 100644 (file)
@@ -57,7 +57,7 @@ snd-soc-wm8770-objs := wm8770.o
 snd-soc-wm8776-objs := wm8776.o
 snd-soc-wm8804-objs := wm8804.o
 snd-soc-wm8900-objs := wm8900.o
-snd-soc-alc5621-objs := alc5621.o
+snd-soc-rt5621-objs := rt5621.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-rt5625-objs := rt5625.o
 snd-soc-cs42l52-objs := cs42l52.o
@@ -154,7 +154,7 @@ obj-$(CONFIG_SND_SOC_WM8770)        += snd-soc-wm8770.o
 obj-$(CONFIG_SND_SOC_WM8776)   += snd-soc-wm8776.o
 obj-$(CONFIG_SND_SOC_WM8804)   += snd-soc-wm8804.o
 obj-$(CONFIG_SND_SOC_WM8900)   += snd-soc-wm8900.o
-obj-$(CONFIG_SND_SOC_alc5621)  += snd-soc-alc5621.o
+obj-$(CONFIG_SND_SOC_RT5621)   += snd-soc-rt5621.o
 obj-$(CONFIG_SND_SOC_RT5631)   += snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_RT5625)   += snd-soc-rt5625.o
 obj-$(CONFIG_SND_SOC_CS42L52)  += snd-soc-cs42l52.o
diff --git a/sound/soc/codecs/alc5621.c b/sound/soc/codecs/alc5621.c
deleted file mode 100644 (file)
index ab04ab7..0000000
+++ /dev/null
@@ -1,1932 +0,0 @@
-#include <linux/module.h>\r
-#include <linux/moduleparam.h>\r
-#include <linux/version.h>\r
-#include <linux/kernel.h>\r
-#include <linux/init.h>\r
-#include <linux/delay.h>\r
-#include <linux/pm.h>\r
-#include <linux/i2c.h>\r
-#include <linux/platform_device.h>\r
-\r
-#include <sound/core.h>\r
-#include <sound/pcm.h>\r
-#include <sound/pcm_params.h>\r
-#include <sound/soc.h>\r
-#include <sound/soc-dapm.h>\r
-#include <sound/initval.h>\r
-#include <asm/div64.h>\r
-#include "alc5621.h"\r
-\r
-#if REALTEK_HWDEP\r
-\r
-#include <linux/ioctl.h>\r
-#include <linux/types.h>\r
-\r
-#endif\r
-\r
-#define AUDIO_NAME "rt5621"\r
-#define RT5621_VERSION "alsa 1.0.21 0.05"\r
-\r
-#ifdef RT5621_DEBUG\r
-#define dbg(format, arg...) \\r
-       printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg)\r
-#else\r
-#define dbg(format, arg...) do {} while (0)\r
-#endif\r
-#define err(format, arg...) \\r
-       printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg)\r
-#define info(format, arg...) \\r
-       printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg)\r
-#define warn(format, arg...) \\r
-       printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg)\r
-       \r
-static int caps_charge = 500;\r
-module_param(caps_charge, int, 0);\r
-MODULE_PARM_DESC(caps_charge, "RT5621 cap charge time (msecs)");\r
-\r
-/* codec private data */\r
-struct rt5621_priv {\r
-       unsigned int sysclk;\r
-};\r
-\r
-static struct snd_soc_device *rt5621_socdev;\r
-\r
-struct rt5621_reg{\r
-\r
-       u8 reg_index;\r
-       u16 reg_value;\r
-};\r
-\r
-static struct rt5621_reg init_data[] = {\r
-       {RT5621_AUDIO_INTERFACE,        0x8000},    //set I2S codec to slave mode\r
-       {RT5621_STEREO_DAC_VOL,         0x0808},    //default stereo DAC volume to 0db\r
-       {RT5621_OUTPUT_MIXER_CTRL,      0x0740},    //default output mixer control      \r
-       {RT5621_ADC_REC_MIXER,          0x3f3f},    //set record source is Mic1 by default\r
-       {RT5621_MIC_CTRL,               0x0500},    //set Mic1,Mic2 boost 20db  \r
-       {RT5621_SPK_OUT_VOL,            0x8080},    //default speaker volume to 0db \r
-       {RT5621_HP_OUT_VOL,             0x8888},    //default HP volume to -12db        \r
-       {RT5621_ADD_CTRL_REG,           0x5f00},    //Class AB/D speaker ratio is 1VDD\r
-       {RT5621_STEREO_AD_DA_CLK_CTRL,  0x066d},    //set Dac filter to 256fs\r
-       {RT5621_HID_CTRL_INDEX,         0x46},      //Class D setting\r
-       {RT5621_HID_CTRL_DATA,          0xFFFF},    //power on Class D Internal register\r
-};\r
-\r
-#define RT5621_INIT_REG_NUM ARRAY_SIZE(init_data)\r
-\r
-/*\r
- * rt5621 register cache\r
- * We can't read the RT5621 register space when we\r
- * are using 2 wire for device control, so we cache them instead.\r
- */\r
-static const u16 rt5621_reg[0x80/2];\r
-\r
-\r
-/* virtual HP mixers regs */\r
-#define HPL_MIXER      0x80\r
-#define HPR_MIXER      0x82\r
-/*reg84*/\r
-/*bit0,1:for hp pga power control\r
- *bit2,3:for aux pga power control\r
- */\r
-#define MISC_FUNC_REG 0x84\r
-static u16 reg80=0,reg82=0, reg84 = 0;\r
-\r
-\r
-/*\r
- * read rt5621 register cache\r
- */\r
-static inline unsigned int rt5621_read_reg_cache(struct snd_soc_codec *codec,\r
-       unsigned int reg)\r
-{\r
-       u16 *cache = codec->reg_cache;\r
-       if (reg < 1 || reg > (ARRAY_SIZE(rt5621_reg) + 1))\r
-               return -1;\r
-       return cache[reg/2];\r
-}\r
-\r
-\r
-/*\r
- * write rt5621 register cache\r
- */\r
-\r
-static inline void rt5621_write_reg_cache(struct snd_soc_codec *codec,\r
-       unsigned int reg, unsigned int value)\r
-{\r
-       u16 *cache = codec->reg_cache;\r
-       if (reg < 0 || reg > 0x7e)\r
-               return;\r
-       cache[reg/2] = value;\r
-}\r
-\r
-\r
-\r
-static int rt5621_write(struct snd_soc_codec *codec, unsigned int reg,\r
-       unsigned int value)\r
-{\r
-       u8 data[3];\r
-\r
-       if(reg>0x7E)\r
-       {\r
-               if(reg==HPL_MIXER)\r
-                       reg80=value;\r
-               else if(reg==HPR_MIXER)\r
-                       reg82=value;\r
-               else if (reg == MISC_FUNC_REG)\r
-                       reg84 = value;\r
-               else\r
-                       return -EIO;\r
-       \r
-               return 0;       \r
-       }       \r
-\r
-\r
-       printk("rt5621 write reg=%x,value=%x\n",reg,value);\r
-       data[0] = reg;\r
-       data[1] = (0xFF00 & value) >> 8;\r
-       data[2] = 0x00FF & value;\r
-\r
-       if (codec->hw_write(codec->control_data, data, 3) == 3)\r
-       {\r
-               rt5621_write_reg_cache (codec, reg, value);             \r
-               printk(KERN_INFO "rt5621 write reg=%x,value=%x\n",reg,value);\r
-               return 0;\r
-       }\r
-       else\r
-       {\r
-               printk(KERN_ERR "rt5621 write faile\n");\r
-               return -EIO;\r
-       }\r
-}\r
-\r
-\r
-static unsigned int rt5621_read(struct snd_soc_codec *codec, unsigned int reg)\r
-{\r
-       u8 data[2]={0};\r
-       unsigned int value=0x0;\r
-\r
-       if(reg>0x7E)\r
-       {\r
-               if(reg==HPL_MIXER)\r
-                return reg80;\r
-               else if(reg==HPR_MIXER)\r
-                return reg82;\r
-               else if (reg == MISC_FUNC_REG)\r
-                       return reg84;\r
-               else\r
-                return -EIO;\r
-                \r
-                return -EIO;   \r
-       }\r
-\r
-\r
-       data[0] = reg;\r
-//flove031811_S\r
-#if 0\r
-      i2c_master_recv(codec->control_data, data, 2);\r
-      \r
-       value = (data[0]<<8) | data[1];         \r
-       printk("rt5621_read reg%x=%x\n",reg,value);\r
-#elif 1\r
-\r
-       i2c_master_reg8_recv(codec->control_data,reg,data, 2,100 * 1000);\r
-\r
-             value = (data[0]<<8) | data[1];         \r
-       printk("rt5621_read reg%x=%x\n",reg,value);\r
-          return value;\r
-\r
-#else  \r
-       if(codec->hw_write(codec->control_data, data, 1) ==1)\r
-       {\r
-               i2c_master_recv(codec->control_data, data, 2);\r
-\r
-               value = (data[0]<<8) | data[1];         \r
-               printk(KERN_DEBUG "rt5621 read reg%x=%x\n",reg,value);\r
-               \r
-               return value;\r
-       }\r
-       else\r
-       {\r
-               printk(KERN_ERR "rt5621 read faile\n");\r
-               return -EIO;                    \r
-       }               \r
-#endif\r
-//flove031811_E        \r
-}\r
-\r
-#define rt5621_write_mask(c, reg, value, mask) snd_soc_update_bits(c, reg, mask, value)\r
-\r
-\r
-#define rt5621_reset(c) rt5621_write(c, 0x0, 0)\r
-\r
-static unsigned int rt5621_read_index(struct snd_soc_codec *codec, unsigned int index)\r
-{\r
-       unsigned int value;\r
-\r
-       rt5621_write(codec, 0x6a, index);\r
-       mdelay(1);\r
-       value = rt5621_read(codec, 0x6c);\r
-       return value;\r
-}\r
-\r
-static int rt5621_init_reg(struct snd_soc_codec *codec)\r
-{\r
-       int i;\r
-\r
-       for (i = 0; i < RT5621_INIT_REG_NUM; i++)\r
-       {\r
-               rt5621_write(codec, init_data[i].reg_index, init_data[i].reg_value);\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-\r
-#if !USE_DAPM_CONTROL\r
-//*****************************************************************************\r
-//\r
-//function:Change audio codec power status\r
-//\r
-//*****************************************************************************\r
-static int rt5621_ChangeCodecPowerStatus(struct snd_soc_codec *codec,int power_state)\r
-{\r
-       unsigned short int PowerDownState=0;\r
-\r
-       switch(power_state)\r
-       {\r
-               case POWER_STATE_D0:                    //FULL ON-----power on all power\r
-                       \r
-                       rt5621_write(codec,RT5621_PWR_MANAG_ADD1,~PowerDownState);\r
-                       rt5621_write(codec,RT5621_PWR_MANAG_ADD2,~PowerDownState);\r
-                       rt5621_write(codec,RT5621_PWR_MANAG_ADD3,~PowerDownState);\r
-\r
-               break;  \r
-\r
-               case POWER_STATE_D1:            //LOW ON-----\r
-\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2 ,PWR_VREF |PWR_DAC_REF_CIR |PWR_L_DAC_CLK |PWR_R_DAC_CLK |PWR_L_HP_MIXER |PWR_R_HP_MIXER|\r
-                                                                                                        PWR_L_ADC_CLK_GAIN |PWR_R_ADC_CLK_GAIN |PWR_L_ADC_REC_MIXER |PWR_R_ADC_REC_MIXER|PWR_CLASS_AB\r
-                                                                                                       ,PWR_VREF |PWR_DAC_REF_CIR |PWR_L_DAC_CLK |PWR_R_DAC_CLK |PWR_L_HP_MIXER |PWR_R_HP_MIXER|\r
-                                                                                                        PWR_L_ADC_CLK_GAIN |PWR_R_ADC_CLK_GAIN |PWR_L_ADC_REC_MIXER |PWR_R_ADC_REC_MIXER|PWR_CLASS_AB);\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD3 ,PWR_MAIN_BIAS|PWR_HP_R_OUT_VOL|PWR_HP_L_OUT_VOL|PWR_SPK_OUT|\r
-                                                                                                        PWR_MIC1_FUN_CTRL|PWR_MIC1_BOOST_MIXER\r
-                                                                                                       ,PWR_MAIN_BIAS|PWR_HP_R_OUT_VOL|PWR_HP_L_OUT_VOL|PWR_SPK_OUT|\r
-                                                                                                        PWR_MIC1_FUN_CTRL|PWR_MIC1_BOOST_MIXER);                       \r
-\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1 ,PWR_MAIN_I2S_EN|PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP|PWR_MIC1_BIAS_EN\r
-                                                                                                       ,PWR_MAIN_I2S_EN|PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP|PWR_MIC1_BIAS_EN);\r
-                                               \r
-               break;\r
-\r
-               case POWER_STATE_D1_PLAYBACK:   //Low on of Playback\r
-\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2,PWR_VREF|PWR_DAC_REF_CIR|PWR_L_DAC_CLK|PWR_R_DAC_CLK|PWR_L_HP_MIXER|PWR_R_HP_MIXER|PWR_CLASS_AB|PWR_CLASS_D\r
-                                                                                                                ,PWR_VREF|PWR_DAC_REF_CIR|PWR_L_DAC_CLK|PWR_R_DAC_CLK|PWR_L_HP_MIXER|PWR_R_HP_MIXER|PWR_CLASS_AB|PWR_CLASS_D);\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD3,PWR_MAIN_BIAS|PWR_HP_R_OUT_VOL|PWR_HP_L_OUT_VOL|PWR_SPK_OUT \r
-                                                                                                                ,PWR_MAIN_BIAS|PWR_HP_R_OUT_VOL|PWR_HP_L_OUT_VOL|PWR_SPK_OUT);         \r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1,PWR_MAIN_I2S_EN|PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP\r
-                                                                                                                ,PWR_MAIN_I2S_EN|PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP);\r
-                                                                       \r
-\r
-               break;\r
-\r
-               case POWER_STATE_D1_RECORD:     //Low on of Record\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1 ,PWR_MAIN_I2S_EN|PWR_MIC1_BIAS_EN\r
-                                                                                                                 ,PWR_MAIN_I2S_EN|PWR_MIC1_BIAS_EN);                                                                                      \r
-                                                                                       \r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2 ,PWR_VREF|PWR_L_ADC_CLK_GAIN|PWR_R_ADC_CLK_GAIN|PWR_L_ADC_REC_MIXER|PWR_R_ADC_REC_MIXER\r
-                                                                                                             ,PWR_VREF|PWR_L_ADC_CLK_GAIN|PWR_R_ADC_CLK_GAIN|PWR_L_ADC_REC_MIXER|PWR_R_ADC_REC_MIXER);\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD3 ,PWR_MAIN_BIAS|PWR_MIC2_BOOST_MIXER|PWR_MIC1_BOOST_MIXER\r
-                                                                                                             ,PWR_MAIN_BIAS|PWR_MIC2_BOOST_MIXER|PWR_MIC1_BOOST_MIXER);                \r
-       \r
-               break;\r
-\r
-               case POWER_STATE_D2:            //STANDBY----\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1 ,0,PWR_MAIN_I2S_EN|PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP|PWR_MIC1_BIAS_EN);                                                                                      \r
-\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD3 ,0,PWR_HP_R_OUT_VOL|PWR_HP_L_OUT_VOL|PWR_SPK_OUT|PWR_MIC1_FUN_CTRL|PWR_MIC1_BOOST_MIXER);\r
-\r
-                                                                                                               \r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2 ,0,PWR_DAC_REF_CIR |PWR_L_DAC_CLK |PWR_R_DAC_CLK |PWR_L_HP_MIXER |PWR_R_HP_MIXER|\r
-                                                                                                                        PWR_L_ADC_CLK_GAIN |PWR_R_ADC_CLK_GAIN |PWR_L_ADC_REC_MIXER |PWR_R_ADC_REC_MIXER|PWR_CLASS_AB|PWR_CLASS_D);\r
-\r
-               \r
-               break;\r
-\r
-               case POWER_STATE_D2_PLAYBACK:   //STANDBY of playback\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD3 ,0,/*PWR_HP_R_OUT_VOL|PWR_HP_L_OUT_VOL|*/PWR_SPK_OUT);\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1 ,0,PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP);                                                                                       \r
-                                                                       \r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2 ,0,PWR_DAC_REF_CIR|PWR_L_DAC_CLK|PWR_R_DAC_CLK|PWR_L_HP_MIXER|PWR_R_HP_MIXER|PWR_CLASS_AB|PWR_CLASS_D);\r
-\r
-               break;\r
-\r
-               case POWER_STATE_D2_RECORD:             //STANDBY of record\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1 ,0,PWR_MIC1_BIAS_EN);                                                                                        \r
-                                                                                       \r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2 ,0,PWR_L_ADC_CLK_GAIN|PWR_R_ADC_CLK_GAIN|PWR_L_ADC_REC_MIXER|PWR_R_ADC_REC_MIXER);\r
-\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD3 ,0,PWR_MIC2_BOOST_MIXER|PWR_MIC1_BOOST_MIXER);            \r
-\r
-               break;          \r
-\r
-               case POWER_STATE_D3:            //SLEEP\r
-               case POWER_STATE_D4:            //OFF----power off all power\r
-                       rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD1 ,0,PWR_HP_OUT_ENH_AMP|PWR_HP_OUT_AMP);            \r
-                       rt5621_write(codec,RT5621_PWR_MANAG_ADD3,0);\r
-                       rt5621_write(codec,RT5621_PWR_MANAG_ADD1,0);\r
-                       rt5621_write(codec,RT5621_PWR_MANAG_ADD2,0);\r
-                                               \r
-               break;  \r
-\r
-               default:\r
-\r
-               break;\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-\r
-//*****************************************************************************\r
-//\r
-//function AudioOutEnable:Mute/Unmute audio out channel\r
-//                                                     WavOutPath:output channel\r
-//                                                     Mute :Mute/Unmute output channel                                                                                        \r
-//\r
-//*****************************************************************************\r
-static int rt5621_AudioOutEnable(struct snd_soc_codec *codec,unsigned short int WavOutPath,int Mute)\r
-{\r
-       int RetVal=0;   \r
-\r
-       if(Mute)\r
-       {\r
-               switch(WavOutPath)\r
-               {\r
-                       case RT_WAVOUT_ALL_ON:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_SPK_OUT_VOL,RT_L_MUTE|RT_R_MUTE,RT_L_MUTE|RT_R_MUTE);     //Mute Speaker right/left channel\r
-                               RetVal=rt5621_write_mask(codec,RT5621_HP_OUT_VOL,RT_L_MUTE|RT_R_MUTE,RT_L_MUTE|RT_R_MUTE);      //Mute headphone right/left channel\r
-                               RetVal=rt5621_write_mask(codec,RT5621_MONO_AUX_OUT_VOL,RT_L_MUTE|RT_R_MUTE,RT_L_MUTE|RT_R_MUTE);        //Mute Aux/Mono right/left channel\r
-                               RetVal=rt5621_write_mask(codec,RT5621_STEREO_DAC_VOL,RT_M_HP_MIXER|RT_M_SPK_MIXER|RT_M_MONO_MIXER\r
-                                                                                                                         ,RT_M_HP_MIXER|RT_M_SPK_MIXER|RT_M_MONO_MIXER);       //Mute DAC to HP,Speaker,Mono Mixer\r
-               \r
-                       break;\r
-               \r
-                       case RT_WAVOUT_HP:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_HP_OUT_VOL,RT_L_MUTE|RT_R_MUTE,RT_L_MUTE|RT_R_MUTE);      //Mute headphone right/left channel\r
-                       \r
-                       break;\r
-\r
-                       case RT_WAVOUT_SPK:\r
-                               \r
-                               RetVal=rt5621_write_mask(codec,RT5621_SPK_OUT_VOL,RT_L_MUTE|RT_R_MUTE,RT_L_MUTE|RT_R_MUTE);     //Mute Speaker right/left channel                       \r
-\r
-                       break;\r
-                       \r
-                       case RT_WAVOUT_AUXOUT:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_MONO_AUX_OUT_VOL,RT_L_MUTE|RT_R_MUTE,RT_L_MUTE|RT_R_MUTE);        //Mute AuxOut right/left channel\r
-\r
-                       break;\r
-\r
-                       case RT_WAVOUT_MONO:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_MONO_AUX_OUT_VOL,RT_L_MUTE,RT_L_MUTE);    //Mute MonoOut channel          \r
-\r
-                       break;\r
-\r
-                       case RT_WAVOUT_DAC:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_STEREO_DAC_VOL,RT_M_HP_MIXER|RT_M_SPK_MIXER|RT_M_MONO_MIXER\r
-                                                                                                                         ,RT_M_HP_MIXER|RT_M_SPK_MIXER|RT_M_MONO_MIXER);       //Mute DAC to HP,Speaker,Mono Mixer                             \r
-                       break;\r
-\r
-                       default:\r
-\r
-                               return 0;\r
-\r
-               }\r
-       }\r
-       else\r
-       {\r
-               switch(WavOutPath)\r
-               {\r
-\r
-                       case RT_WAVOUT_ALL_ON:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_SPK_OUT_VOL               ,0,RT_L_MUTE|RT_R_MUTE);        //Mute Speaker right/left channel\r
-                               RetVal=rt5621_write_mask(codec,RT5621_HP_OUT_VOL                ,0,RT_L_MUTE|RT_R_MUTE);        //Mute headphone right/left channel\r
-                               RetVal=rt5621_write_mask(codec,RT5621_MONO_AUX_OUT_VOL  ,0,RT_L_MUTE|RT_R_MUTE);        //Mute Aux/Mono right/left channel\r
-                               RetVal=rt5621_write_mask(codec,RT5621_STEREO_DAC_VOL    ,0,RT_M_HP_MIXER|RT_M_SPK_MIXER|RT_M_MONO_MIXER);       //Mute DAC to HP,Speaker,Mono Mixer\r
-               \r
-                       break;\r
-               \r
-                       case RT_WAVOUT_HP:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_HP_OUT_VOL,0,RT_L_MUTE|RT_R_MUTE);        //UnMute headphone right/left channel   \r
-                                       \r
-                       break;\r
-\r
-                       case RT_WAVOUT_SPK:\r
-                               \r
-                               RetVal=rt5621_write_mask(codec,RT5621_SPK_OUT_VOL,0,RT_L_MUTE|RT_R_MUTE);       //unMute Speaker right/left channel                     \r
-\r
-                       break;\r
-                       \r
-                       case RT_WAVOUT_AUXOUT:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_MONO_AUX_OUT_VOL,0,RT_L_MUTE|RT_R_MUTE);//unMute AuxOut right/left channel\r
-\r
-                       break;\r
-\r
-                       case RT_WAVOUT_MONO:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_MONO_AUX_OUT_VOL,0,RT_L_MUTE);    //unMute MonoOut channel                \r
-\r
-                       break;\r
-\r
-                       case RT_WAVOUT_DAC:\r
-\r
-                               RetVal=rt5621_write_mask(codec,RT5621_STEREO_DAC_VOL,0,RT_M_HP_MIXER|RT_M_SPK_MIXER|RT_M_MONO_MIXER);   //unMute DAC to HP,Speaker,Mono Mixer\r
-\r
-                       default:\r
-                               return 0;\r
-               }\r
-\r
-       }\r
-       \r
-       return RetVal;\r
-}\r
-\r
-\r
-//*****************************************************************************\r
-//\r
-//function:Enable/Disable ADC input source control\r
-//\r
-//*****************************************************************************\r
-static int Enable_ADC_Input_Source(struct snd_soc_codec *codec,unsigned short int ADC_Input_Sour,int Enable)\r
-{\r
-       int bRetVal=0;\r
-       \r
-       if(Enable)\r
-       {\r
-               //Enable ADC source \r
-               bRetVal=rt5621_write_mask(codec,RT5621_ADC_REC_MIXER,0,ADC_Input_Sour);\r
-       }\r
-       else\r
-       {\r
-               //Disable ADC source            \r
-               bRetVal=rt5621_write_mask(codec,RT5621_ADC_REC_MIXER,ADC_Input_Sour,ADC_Input_Sour);\r
-       }\r
-\r
-       return bRetVal;\r
-}\r
-#endif\r
-\r
-\r
-//static const char *rt5621_spkl_pga[] = {"Vmid","HPL mixer","SPK mixer","Mono Mixer"};\r
-static const char *rt5621_spkn_source_sel[] = {"RN", "RP", "LN"};\r
-static const char *rt5621_spk_pga[] = {"Vmid","HP mixer","SPK mixer","Mono Mixer"};\r
-static const char *rt5621_hpl_pga[]  = {"Vmid","HPL mixer"};\r
-static const char *rt5621_hpr_pga[]  = {"Vmid","HPR mixer"};\r
-static const char *rt5621_mono_pga[] = {"Vmid","HP mixer","SPK mixer","Mono Mixer"};\r
-static const char *rt5621_amp_type_sel[] = {"Class AB","Class D"};\r
-static const char *rt5621_mic_boost_sel[] = {"Bypass","20db","30db","40db"};\r
-\r
-static const struct soc_enum rt5621_enum[] = {\r
-SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 14, 3, rt5621_spkn_source_sel), /* spkn source from hp mixer */      \r
-SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 10, 4, rt5621_spk_pga), /* spk input sel 1 */        \r
-SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 9, 2, rt5621_hpl_pga), /* hp left input sel 2 */     \r
-SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 8, 2, rt5621_hpr_pga), /* hp right input sel 3 */    \r
-SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 6, 4, rt5621_mono_pga), /* mono input sel 4 */\r
-SOC_ENUM_SINGLE(RT5621_MIC_CTRL                        , 10,4, rt5621_mic_boost_sel), /*Mic1 boost sel 5 */\r
-SOC_ENUM_SINGLE(RT5621_MIC_CTRL                        , 8,4,rt5621_mic_boost_sel), /*Mic2 boost sel 6 */\r
-SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL,13,2,rt5621_amp_type_sel), /*Speaker AMP sel 7 */\r
-};\r
-\r
-static int rt5621_amp_sel_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)\r
-{\r
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);\r
-       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;\r
-       unsigned short val;\r
-       unsigned short mask, bitmask;\r
-\r
-       for (bitmask = 1; bitmask < e->max; bitmask <<= 1)\r
-               ;\r
-       if (ucontrol->value.enumerated.item[0] > e->max - 1)\r
-               return -EINVAL;\r
-       val = ucontrol->value.enumerated.item[0] << e->shift_l;\r
-       mask = (bitmask - 1) << e->shift_l;\r
-       if (e->shift_l != e->shift_r) {\r
-               if (ucontrol->value.enumerated.item[1] > e->max - 1)\r
-                       return -EINVAL;\r
-               val |= ucontrol->value.enumerated.item[1] << e->shift_r;\r
-               mask |= (bitmask - 1) << e->shift_r;\r
-       }\r
-\r
-        snd_soc_update_bits(codec, e->reg, mask, val);\r
-        val &= (0x1 << 13);\r
-        if (val == 0)\r
-        {\r
-                snd_soc_update_bits(codec, 0x3c, 0x0000, 0x4000);       /*power off classd*/\r
-                snd_soc_update_bits(codec, 0x3c, 0x8000, 0x8000);       /*power on classab*/\r
-        }\r
-        else\r
-       {\r
-                snd_soc_update_bits(codec, 0x3c, 0x0000, 0x8000);       /*power off classab*/\r
-                snd_soc_update_bits(codec, 0x3c, 0x4000, 0x4000);       /*power on classd*/\r
-        }\r
-       return 0;\r
-}\r
-\r
-\r
-\r
-static const struct snd_kcontrol_new rt5621_snd_controls[] = {\r
-SOC_DOUBLE("Speaker Playback Volume",  RT5621_SPK_OUT_VOL, 8, 0, 31, 1),       \r
-SOC_DOUBLE("Speaker Playback Switch",  RT5621_SPK_OUT_VOL, 15, 7, 1, 1),\r
-SOC_DOUBLE("Headphone Playback Volume", RT5621_HP_OUT_VOL, 8, 0, 31, 1),\r
-SOC_DOUBLE("Headphone Playback Switch", RT5621_HP_OUT_VOL,15, 7, 1, 1),\r
-SOC_DOUBLE("AUX Playback Volume",              RT5621_MONO_AUX_OUT_VOL, 8, 0, 31, 1),\r
-SOC_DOUBLE("AUX Playback Switch",              RT5621_MONO_AUX_OUT_VOL, 15, 7, 1, 1),\r
-SOC_DOUBLE("PCM Playback Volume",              RT5621_STEREO_DAC_VOL, 8, 0, 31, 1),\r
-SOC_DOUBLE("Line In Volume",                   RT5621_LINE_IN_VOL, 8, 0, 31, 1),\r
-SOC_SINGLE("Mic 1 Volume",                             RT5621_MIC_VOL, 8, 31, 1),\r
-SOC_SINGLE("Mic 2 Volume",                             RT5621_MIC_VOL, 0, 31, 1),\r
-SOC_ENUM("Mic 1 Boost",                                rt5621_enum[5]),\r
-SOC_ENUM("Mic 2 Boost",                                rt5621_enum[6]),\r
-SOC_ENUM_EXT("Speaker Amp Type",                       rt5621_enum[7], snd_soc_get_enum_double, rt5621_amp_sel_put),\r
-SOC_DOUBLE("AUX In Volume",                    RT5621_AUXIN_VOL, 8, 0, 31, 1),\r
-SOC_DOUBLE("Capture Volume",                   RT5621_ADC_REC_GAIN, 7, 0, 31, 0),\r
-};\r
-\r
-\r
-\r
-/* add non dapm controls */\r
-static int rt5621_add_controls(struct snd_soc_codec *codec)\r
-{\r
-       int err, i;\r
-\r
-       for (i = 0; i < ARRAY_SIZE(rt5621_snd_controls); i++) {\r
-               err = snd_ctl_add(codec->card,\r
-                               snd_soc_cnew(&rt5621_snd_controls[i],codec, NULL));\r
-               if (err < 0)\r
-                       return err;\r
-       }\r
-       return 0;\r
-}\r
-\r
-void hp_depop_mode2(struct snd_soc_codec *codec)\r
-{\r
-       rt5621_write_mask(codec, 0x3e, 0x8000, 0x8000);\r
-       rt5621_write_mask(codec, 0x04, 0x8080, 0x8080);\r
-       rt5621_write_mask(codec, 0x3a, 0x0100, 0x0100);\r
-       rt5621_write_mask(codec, 0x3c, 0x2000, 0x2000);\r
-       rt5621_write_mask(codec, 0x3e, 0x0600, 0x0600);\r
-       rt5621_write_mask(codec, 0x5e, 0x0200, 0x0200);\r
-       schedule_timeout_uninterruptible(msecs_to_jiffies(300));\r
-}\r
-\r
-void aux_depop_mode2(struct snd_soc_codec *codec)\r
-{\r
-       rt5621_write_mask(codec, 0x3e, 0x8000, 0x8000);\r
-       rt5621_write_mask(codec, 0x06, 0x8080, 0x8080);\r
-       rt5621_write_mask(codec, 0x3a, 0x0100, 0x0100);\r
-       rt5621_write_mask(codec, 0x3c, 0x2000, 0x2000);\r
-       rt5621_write_mask(codec, 0x3e, 0x6000, 0x6000);\r
-       rt5621_write_mask(codec, 0x5e, 0x0020, 0x0200);\r
-       schedule_timeout_uninterruptible(msecs_to_jiffies(300));\r
-       rt5621_write_mask(codec, 0x3a, 0x0002, 0x0002);\r
-       rt5621_write_mask(codec, 0x3a, 0x0001, 0x0001); \r
-}\r
-#if USE_DAPM_CONTROL\r
-\r
-/*\r
- * _DAPM_ Controls\r
- */\r
-\r
-/* We have to create a fake left and right HP mixers because\r
- * the codec only has a single control that is shared by both channels.\r
- * This makes it impossible to determine the audio path using the current\r
- * register map, thus we add a new (virtual) register to help determine the\r
- * audio route within the device.\r
- */\r
- static int mixer_event (struct snd_soc_dapm_widget *w, \r
-       struct snd_kcontrol *kcontrol, int event)\r
-{\r
-\r
-       u16 l, r, lineIn,mic1,mic2, aux, pcm;\r
-\r
-       l = rt5621_read(w->codec, HPL_MIXER);\r
-       r = rt5621_read(w->codec, HPR_MIXER);\r
-       lineIn = rt5621_read(w->codec, RT5621_LINE_IN_VOL);\r
-       mic2 = rt5621_read(w->codec, RT5621_MIC_ROUTING_CTRL);\r
-       aux = rt5621_read(w->codec,RT5621_AUXIN_VOL);\r
-       pcm = rt5621_read(w->codec, RT5621_STEREO_DAC_VOL);\r
-\r
-\r
-       if (event & SND_SOC_DAPM_PRE_REG)\r
-               return 0;\r
-\r
-       if (l & 0x1 || r & 0x1)\r
-               rt5621_write(w->codec, RT5621_STEREO_DAC_VOL, pcm & 0x7fff);\r
-       else\r
-               rt5621_write(w->codec, RT5621_STEREO_DAC_VOL, pcm | 0x8000);\r
-\r
-       if (l & 0x2 || r & 0x2)\r
-               rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic2 & 0xff7f);\r
-       else\r
-               rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic2 | 0x0080);\r
-\r
-       mic1 = rt5621_read(w->codec, RT5621_MIC_ROUTING_CTRL);\r
-       if (l & 0x4 || r & 0x4)\r
-               rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic1 & 0x7fff);\r
-       else\r
-               rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic1 | 0x8000);\r
-\r
-       if (l & 0x8 || r & 0x8)\r
-               rt5621_write(w->codec, RT5621_AUXIN_VOL, aux & 0x7fff);\r
-       else\r
-               rt5621_write(w->codec, RT5621_AUXIN_VOL, aux | 0x8000);\r
-\r
-       if (l & 0x10 || r & 0x10)\r
-               rt5621_write(w->codec, RT5621_LINE_IN_VOL, lineIn & 0x7fff);\r
-       else\r
-               rt5621_write(w->codec, RT5621_LINE_IN_VOL, lineIn | 0x8000);\r
-\r
-       return 0;\r
-}\r
-\r
-\r
-static int hp_event(struct snd_soc_dapm_widget *w, \r
-       struct snd_kcontrol *kcontrol, int event)\r
-{\r
-       struct snd_soc_codec *codec = w->codec;\r
-       unsigned int reg = rt5621_read(codec, MISC_FUNC_REG);\r
-       \r
-       if (((reg & 0x03) != 0x00) && ((reg & 0x03) != 0x03))\r
-               return 0;\r
-       \r
-       switch (event)\r
-       {\r
-               case SND_SOC_DAPM_POST_PMU:\r
-                       hp_depop_mode2(codec);\r
-                       rt5621_write_mask(codec, 0x04, 0x0000, 0x8080);\r
-                       rt5621_write_mask(codec, 0x3a, 0x0020, 0x0020);\r
-                       break;\r
-               case SND_SOC_DAPM_POST_PMD:\r
-                       rt5621_write_mask(codec, 0x04, 0x8080, 0x8080);\r
-                       rt5621_write_mask(codec, 0x3a, 0x0000, 0x0010);\r
-                       rt5621_write_mask(codec, 0x3a, 0x0000, 0x0020);\r
-                       rt5621_write_mask(codec, 0x3e, 0x0000, 0x0600);\r
-                       break;  \r
-       }\r
-       return 0;\r
-}\r
-\r
-static int aux_event(struct snd_soc_dapm_widget *w, \r
-       struct snd_kcontrol *kcontrol, int event)\r
-{\r
-       struct snd_soc_codec *codec = w->codec;\r
-       unsigned int reg = rt5621_read(codec, MISC_FUNC_REG);\r
-       \r
-       if (((reg & 0x0c) != 0x00) && ((reg & 0x0c) != 0x0c))\r
-               return 0;\r
-       \r
-       switch (event)\r
-       {\r
-               case SND_SOC_DAPM_POST_PMU:\r
-                       aux_depop_mode2(codec);\r
-                       rt5621_write_mask(codec, 0x06, 0x0000, 0x8080);\r
-                       break;\r
-               case SND_SOC_DAPM_POST_PMD:\r
-                       rt5621_write_mask(codec, 0x06, 0x8080, 0x8080);\r
-                       rt5621_write_mask(codec, 0x3a, 0x0000, 0x0001);\r
-                       rt5621_write_mask(codec, 0x3a, 0x0000, 0x0002);\r
-                       rt5621_write_mask(codec, 0x3e, 0x0000, 0x6000);         \r
-                       break;\r
-       }\r
-       return 0;\r
-}\r
-\r
-/* Left Headphone Mixers */\r
-static const struct snd_kcontrol_new rt5621_hpl_mixer_controls[] = {\r
-SOC_DAPM_SINGLE("LineIn Playback Switch", HPL_MIXER, 4, 1, 0),\r
-SOC_DAPM_SINGLE("AUXIN Playback Switch", HPL_MIXER, 3, 1, 0),\r
-SOC_DAPM_SINGLE("Mic1 Playback Switch", HPL_MIXER, 2, 1, 0),\r
-SOC_DAPM_SINGLE("Mic2 Playback Switch", HPL_MIXER, 1, 1, 0),\r
-SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 0, 1, 0),\r
-SOC_DAPM_SINGLE("RecordL Playback Switch", RT5621_ADC_REC_GAIN, 15, 1,1),\r
-};\r
-\r
-/* Right Headphone Mixers */\r
-static const struct snd_kcontrol_new rt5621_hpr_mixer_controls[] = {\r
-SOC_DAPM_SINGLE("LineIn Playback Switch", HPR_MIXER, 4, 1, 0),\r
-SOC_DAPM_SINGLE("AUXIN Playback Switch", HPR_MIXER, 3, 1, 0),\r
-SOC_DAPM_SINGLE("Mic1 Playback Switch", HPR_MIXER, 2, 1, 0),\r
-SOC_DAPM_SINGLE("Mic2 Playback Switch", HPR_MIXER, 1, 1, 0),\r
-SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 0, 1, 0),\r
-SOC_DAPM_SINGLE("RecordR Playback Switch", RT5621_ADC_REC_GAIN, 14, 1,1),\r
-};\r
-\r
-//Left Record Mixer\r
-static const struct snd_kcontrol_new rt5621_captureL_mixer_controls[] = {\r
-SOC_DAPM_SINGLE("Mic1 Capture Switch", RT5621_ADC_REC_MIXER, 14, 1, 1),\r
-SOC_DAPM_SINGLE("Mic2 Capture Switch", RT5621_ADC_REC_MIXER, 13, 1, 1),\r
-SOC_DAPM_SINGLE("LineInL Capture Switch",RT5621_ADC_REC_MIXER,12, 1, 1),\r
-SOC_DAPM_SINGLE("AUXIN Capture Switch", RT5621_ADC_REC_MIXER, 11, 1, 1),\r
-SOC_DAPM_SINGLE("HPMixerL Capture Switch", RT5621_ADC_REC_MIXER,10, 1, 1),\r
-SOC_DAPM_SINGLE("SPKMixer Capture Switch",RT5621_ADC_REC_MIXER,9, 1, 1),\r
-SOC_DAPM_SINGLE("MonoMixer Capture Switch",RT5621_ADC_REC_MIXER,8, 1, 1),\r
-};\r
-\r
-\r
-//Right Record Mixer\r
-static const struct snd_kcontrol_new rt5621_captureR_mixer_controls[] = {\r
-SOC_DAPM_SINGLE("Mic1 Capture Switch", RT5621_ADC_REC_MIXER, 6, 1, 1),\r
-SOC_DAPM_SINGLE("Mic2 Capture Switch", RT5621_ADC_REC_MIXER, 5, 1, 1),\r
-SOC_DAPM_SINGLE("LineInR Capture Switch",RT5621_ADC_REC_MIXER,4, 1, 1),\r
-SOC_DAPM_SINGLE("AUXIN Capture Switch", RT5621_ADC_REC_MIXER, 3, 1, 1),\r
-SOC_DAPM_SINGLE("HPMixerR Capture Switch", RT5621_ADC_REC_MIXER,2, 1, 1),\r
-SOC_DAPM_SINGLE("SPKMixer Capture Switch",RT5621_ADC_REC_MIXER,1, 1, 1),\r
-SOC_DAPM_SINGLE("MonoMixer Capture Switch",RT5621_ADC_REC_MIXER,0, 1, 1),\r
-};\r
-\r
-/* Speaker Mixer */\r
-static const struct snd_kcontrol_new rt5621_speaker_mixer_controls[] = {\r
-SOC_DAPM_SINGLE("LineIn Playback Switch", RT5621_LINE_IN_VOL, 14, 1, 1),\r
-SOC_DAPM_SINGLE("AUXIN Playback Switch", RT5621_AUXIN_VOL, 14, 1, 1),\r
-SOC_DAPM_SINGLE("Mic1 Playback Switch", RT5621_MIC_ROUTING_CTRL, 14, 1, 1),\r
-SOC_DAPM_SINGLE("Mic2 Playback Switch", RT5621_MIC_ROUTING_CTRL, 6, 1, 1),\r
-SOC_DAPM_SINGLE("PCM Playback Switch", RT5621_STEREO_DAC_VOL, 14, 1, 1),\r
-};\r
-\r
-\r
-/* Mono Mixer */\r
-static const struct snd_kcontrol_new rt5621_mono_mixer_controls[] = {\r
-SOC_DAPM_SINGLE("LineIn Playback Switch", RT5621_LINE_IN_VOL, 13, 1, 1),\r
-SOC_DAPM_SINGLE("Mic1 Playback Switch", RT5621_MIC_ROUTING_CTRL, 13, 1, 1),\r
-SOC_DAPM_SINGLE("Mic2 Playback Switch", RT5621_MIC_ROUTING_CTRL, 5, 1, 1),\r
-SOC_DAPM_SINGLE("AUXIN Playback Switch", RT5621_AUXIN_VOL, 13, 1, 1),\r
-SOC_DAPM_SINGLE("PCM Playback Switch", RT5621_STEREO_DAC_VOL, 13, 1, 1),\r
-SOC_DAPM_SINGLE("RecordL Playback Switch", RT5621_ADC_REC_GAIN, 13, 1,1),\r
-SOC_DAPM_SINGLE("RecordR Playback Switch", RT5621_ADC_REC_GAIN, 12, 1,1),\r
-};\r
-\r
-/* mono output mux */\r
-static const struct snd_kcontrol_new rt5621_mono_mux_controls =\r
-SOC_DAPM_ENUM("Route", rt5621_enum[4]);\r
-\r
-/* speaker left output mux */\r
-static const struct snd_kcontrol_new rt5621_hp_spk_mux_controls =\r
-SOC_DAPM_ENUM("Route", rt5621_enum[1]);\r
-\r
-\r
-/* headphone left output mux */\r
-static const struct snd_kcontrol_new rt5621_hpl_out_mux_controls =\r
-SOC_DAPM_ENUM("Route", rt5621_enum[2]);\r
-\r
-/* headphone right output mux */\r
-static const struct snd_kcontrol_new rt5621_hpr_out_mux_controls =\r
-SOC_DAPM_ENUM("Route", rt5621_enum[3]);\r
-\r
-static const struct snd_soc_dapm_widget rt5621_dapm_widgets[] = {\r
-SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 0, 0,\r
-       &rt5621_mono_mux_controls),\r
-SND_SOC_DAPM_MUX("Speaker Out Mux", SND_SOC_NOPM, 0, 0,\r
-       &rt5621_hp_spk_mux_controls),\r
-SND_SOC_DAPM_MUX("Left Headphone Out Mux", SND_SOC_NOPM, 0, 0,\r
-       &rt5621_hpl_out_mux_controls),\r
-SND_SOC_DAPM_MUX("Right Headphone Out Mux", SND_SOC_NOPM, 0, 0,\r
-       &rt5621_hpr_out_mux_controls),\r
-       \r
-SND_SOC_DAPM_MIXER_E("Left HP Mixer",RT5621_PWR_MANAG_ADD2, 5, 0,\r
-       &rt5621_hpl_mixer_controls[0], ARRAY_SIZE(rt5621_hpl_mixer_controls),\r
-       mixer_event, SND_SOC_DAPM_POST_REG),    \r
-SND_SOC_DAPM_MIXER_E("Right HP Mixer",RT5621_PWR_MANAG_ADD2, 4, 0,\r
-       &rt5621_hpr_mixer_controls[0], ARRAY_SIZE(rt5621_hpr_mixer_controls),\r
-       mixer_event, SND_SOC_DAPM_POST_REG),    \r
-SND_SOC_DAPM_MIXER("Mono Mixer", RT5621_PWR_MANAG_ADD2, 2, 0,\r
-       &rt5621_mono_mixer_controls[0], ARRAY_SIZE(rt5621_mono_mixer_controls)),\r
-       \r
-SND_SOC_DAPM_MIXER("Speaker Mixer", RT5621_PWR_MANAG_ADD2,3,0,\r
-       &rt5621_speaker_mixer_controls[0], ARRAY_SIZE(rt5621_speaker_mixer_controls)),  \r
-       \r
-SND_SOC_DAPM_MIXER("Left Record Mixer", RT5621_PWR_MANAG_ADD2,1,0,\r
-       &rt5621_captureL_mixer_controls[0],     ARRAY_SIZE(rt5621_captureL_mixer_controls)),    \r
-SND_SOC_DAPM_MIXER("Right Record Mixer", RT5621_PWR_MANAG_ADD2,0,0,\r
-       &rt5621_captureR_mixer_controls[0],     ARRAY_SIZE(rt5621_captureR_mixer_controls)),    \r
-       \r
-SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", RT5621_PWR_MANAG_ADD2,9, 0),\r
-SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", RT5621_PWR_MANAG_ADD2, 8, 0),\r
-\r
-SND_SOC_DAPM_MIXER("IIS Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),\r
-SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),\r
-\r
-SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),\r
-SND_SOC_DAPM_MIXER("AUXIN Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),\r
-\r
-SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", RT5621_PWR_MANAG_ADD2, 7, 0),\r
-SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", RT5621_PWR_MANAG_ADD2, 6, 0),\r
-\r
-SND_SOC_DAPM_PGA_E("Left Headphone", MISC_FUNC_REG, 0, 0, NULL, 0, \r
-       hp_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),\r
-SND_SOC_DAPM_PGA_E("Right Headphone", MISC_FUNC_REG, 1, 0, NULL, 0, \r
-       hp_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),\r
-\r
-SND_SOC_DAPM_PGA("Speaker PGA", RT5621_PWR_MANAG_ADD3, 12, 0, NULL, 0),\r
-\r
-SND_SOC_DAPM_PGA_E("AUXL Out", MISC_FUNC_REG, 2, 0, NULL, 0,\r
-       aux_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),\r
-SND_SOC_DAPM_PGA_E("AUXR Out", MISC_FUNC_REG, 3, 0, NULL, 0,\r
-       aux_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU),\r
-\r
-SND_SOC_DAPM_PGA("Left Line In", RT5621_PWR_MANAG_ADD3, 7, 0, NULL, 0),\r
-SND_SOC_DAPM_PGA("Right Line In", RT5621_PWR_MANAG_ADD3, 6, 0, NULL, 0),\r
-SND_SOC_DAPM_PGA("Left AUX In", RT5621_PWR_MANAG_ADD3, 5, 0, NULL, 0),\r
-SND_SOC_DAPM_PGA("Right AUX In", RT5621_PWR_MANAG_ADD3, 4, 0, NULL, 0),\r
-\r
-SND_SOC_DAPM_PGA("Mic 1 PGA", RT5621_PWR_MANAG_ADD3, 3, 0, NULL, 0),\r
-SND_SOC_DAPM_PGA("Mic 2 PGA", RT5621_PWR_MANAG_ADD3, 2, 0, NULL, 0),\r
-SND_SOC_DAPM_PGA("Mic 1 Pre Amp", RT5621_PWR_MANAG_ADD3, 1, 0, NULL, 0),\r
-SND_SOC_DAPM_PGA("Mic 2 Pre Amp", RT5621_PWR_MANAG_ADD3, 0, 0, NULL, 0),\r
-\r
-SND_SOC_DAPM_MICBIAS("Mic Bias1", RT5621_PWR_MANAG_ADD1, 11, 0),\r
-\r
-SND_SOC_DAPM_OUTPUT("AUXL"),\r
-SND_SOC_DAPM_OUTPUT("AUXR"),\r
-SND_SOC_DAPM_OUTPUT("HPL"),\r
-SND_SOC_DAPM_OUTPUT("HPR"),\r
-SND_SOC_DAPM_OUTPUT("SPK"),\r
-\r
-SND_SOC_DAPM_INPUT("LINEL"),\r
-SND_SOC_DAPM_INPUT("LINER"),\r
-SND_SOC_DAPM_INPUT("AUXINL"),\r
-SND_SOC_DAPM_INPUT("AUXINR"),\r
-SND_SOC_DAPM_INPUT("MIC1"),\r
-SND_SOC_DAPM_INPUT("MIC2"),\r
-SND_SOC_DAPM_VMID("VMID"),\r
-};\r
-\r
-static const struct snd_soc_dapm_route audio_map[] = {\r
-       /* left HP mixer */\r
-       {"Left HP Mixer"        ,       "LineIn Playback Switch"                ,       "Left Line In"},\r
-       {"Left HP Mixer"        ,       "AUXIN Playback Switch"         ,       "Left AUX In"},\r
-       {"Left HP Mixer"        ,       "Mic1 Playback Switch"                  ,       "Mic 1 PGA"},\r
-       {"Left HP Mixer"        ,       "Mic2 Playback Switch"                  ,       "Mic 2 PGA"},\r
-       {"Left HP Mixer"        ,       "PCM Playback Switch"                   ,       "Left DAC"},\r
-       {"Left HP Mixer"        ,       "RecordL Playback Switch"               ,       "Left Record Mixer"},\r
-       \r
-       /* right HP mixer */\r
-       {"Right HP Mixer"       ,       "LineIn Playback Switch"                ,       "Right Line In"},\r
-       {"Right HP Mixer"       ,       "AUXIN Playback Switch"         ,       "Right AUX In"},\r
-       {"Right HP Mixer"       ,       "Mic1 Playback Switch"                  ,       "Mic 1 PGA"},\r
-       {"Right HP Mixer"       ,       "Mic2 Playback Switch"                  ,       "Mic 2 PGA"},\r
-       {"Right HP Mixer"       ,       "PCM Playback Switch"                   ,       "Right DAC"},\r
-       {"Right HP Mixer"       ,       "RecordR Playback Switch"               ,       "Right Record Mixer"},\r
-       \r
-       /* virtual mixer - mixes left & right channels for spk and mono */\r
-       {"IIS Mixer"            ,       NULL                                            ,       "Left DAC"},\r
-       {"IIS Mixer"            ,       NULL                                            ,       "Right DAC"},\r
-       {"Line Mixer"           ,       NULL                                            ,       "Right Line In"},\r
-       {"Line Mixer"           ,       NULL                                            ,       "Left Line In"},\r
-       {"AUXIN Mixer"  ,       NULL                                            ,       "Left AUX In"},\r
-       {"AUXIN Mixer"  ,       NULL                                            ,       "Right AUX In"},\r
-       {"HP Mixer"             ,       NULL                                            ,       "Left HP Mixer"},\r
-       {"HP Mixer"             ,       NULL                                            ,       "Right HP Mixer"},\r
-       \r
-       /* speaker mixer */\r
-       {"Speaker Mixer"        ,       "LineIn Playback Switch"                ,       "Line Mixer"},\r
-       {"Speaker Mixer"        ,       "AUXIN Playback Switch"         ,       "AUXIN Mixer"},\r
-       {"Speaker Mixer"        ,       "Mic1 Playback Switch"                  ,       "Mic 1 PGA"},\r
-       {"Speaker Mixer"        ,       "Mic2 Playback Switch"                  ,       "Mic 2 PGA"},\r
-       {"Speaker Mixer"        ,       "PCM Playback Switch"                   ,       "IIS Mixer"},\r
-\r
-\r
-       /* mono mixer */\r
-       {"Mono Mixer"           ,       "LineIn Playback Switch"                ,       "Line Mixer"},\r
-       {"Mono Mixer"           ,       "Mic1 Playback Switch"                  ,       "Mic 1 PGA"},\r
-       {"Mono Mixer"           ,       "Mic2 Playback Switch"                  ,       "Mic 2 PGA"},\r
-       {"Mono Mixer"           ,       "PCM Playback Switch"                   ,       "IIS Mixer"},\r
-       {"Mono Mixer"           ,       "AUXIN Playback Switch"         ,       "AUXIN Mixer"},\r
-       {"Mono Mixer"           ,       "RecordL Playback Switch"               ,       "Left Record Mixer"},\r
-       {"Mono Mixer"           ,       "RecordR Playback Switch"               ,       "Right Record Mixer"},\r
-       \r
-       /*Left record mixer */\r
-       {"Left Record Mixer"    ,       "Mic1 Capture Switch"           ,       "Mic 1 Pre Amp"},\r
-       {"Left Record Mixer"    ,       "Mic2 Capture Switch"           ,       "Mic 2 Pre Amp"},\r
-       {"Left Record Mixer"    ,       "LineInL Capture Switch"        ,       "LINEL"},\r
-       {"Left Record Mixer"    ,       "AUXIN Capture Switch"          ,       "AUXINL"},\r
-       {"Left Record Mixer"    ,       "HPMixerL Capture Switch"       ,       "Left HP Mixer"},\r
-       {"Left Record Mixer"    ,       "SPKMixer Capture Switch"       ,       "Speaker Mixer"},\r
-       {"Left Record Mixer"    ,       "MonoMixer Capture Switch"      ,       "Mono Mixer"},\r
-       \r
-       /*Right record mixer */\r
-       {"Right Record Mixer"   ,       "Mic1 Capture Switch"           ,       "Mic 1 Pre Amp"},\r
-       {"Right Record Mixer"   ,        "Mic2 Capture Switch"          ,       "Mic 2 Pre Amp"},\r
-       {"Right Record Mixer"   ,       "LineInR Capture Switch"        ,       "LINER"},\r
-       {"Right Record Mixer"   ,       "AUXIN Capture Switch"          ,       "AUXINR"},\r
-       {"Right Record Mixer"   ,       "HPMixerR Capture Switch"       ,       "Right HP Mixer"},\r
-       {"Right Record Mixer"   ,       "SPKMixer Capture Switch"       ,       "Speaker Mixer"},\r
-       {"Right Record Mixer"   ,        "MonoMixer Capture Switch"     ,       "Mono Mixer"},  \r
-\r
-       /* headphone left mux */\r
-       {"Left Headphone Out Mux"       ,        "HPL mixer"                    ,        "Left HP Mixer"},\r
-\r
-       /* headphone right mux */\r
-       {"Right Headphone Out Mux", "HPR mixer", "Right HP Mixer"},\r
-\r
-       /* speaker mux */\r
-       {"Speaker Out Mux", "HP mixer", "HP Mixer"},\r
-       {"Speaker Out Mux", "SPK mixer", "Speaker Mixer"},\r
-       {"Speaker Out Mux", "Mono Mixer", "Mono Mixer"},\r
-\r
-       /* mono mux */\r
-       {"Mono Out Mux", "HP mixer", "HP Mixer"},\r
-       {"Mono Out Mux", "SPK mixer", "Speaker Mixer"},\r
-       {"Mono Out Mux", "Mono Mixer", "Mono Mixer"},\r
-       \r
-       /* output pga */\r
-       {"HPL", NULL, "Left Headphone"},\r
-       {"Left Headphone", NULL, "Left Headphone Out Mux"},\r
-\r
-       {"HPR", NULL, "Right Headphone"},\r
-       {"Right Headphone", NULL, "Right Headphone Out Mux"},\r
-\r
-       {"SPK", NULL, "Speaker PGA"},\r
-       {"Speaker PGA", NULL, "Speaker Out Mux"},\r
-\r
-       {"AUXL", NULL, "AUXL Out"},\r
-       {"AUXL Out", NULL, "Mono Out Mux"},\r
-\r
-       {"AUXR", NULL, "AUXR Out"},\r
-       {"AUXR Out", NULL, "Mono Out Mux"},\r
-\r
-       /* input pga */\r
-       {"Left Line In", NULL, "LINEL"},\r
-       {"Right Line In", NULL, "LINER"},\r
-       \r
-       {"Left AUX In", NULL, "AUXINL"},\r
-       {"Right AUX In", NULL, "AUXINR"},\r
-       \r
-       {"Mic 1 Pre Amp", NULL, "MIC1"},\r
-       {"Mic 2 Pre Amp", NULL, "MIC2"},        \r
-       {"Mic 1 PGA", NULL, "Mic 1 Pre Amp"},\r
-       {"Mic 2 PGA", NULL, "Mic 2 Pre Amp"},\r
-\r
-       /* left ADC */\r
-       {"Left ADC", NULL, "Left Record Mixer"},\r
-\r
-       /* right ADC */\r
-       {"Right ADC", NULL, "Right Record Mixer"},\r
-       \r
-};\r
-\r
-static int rt5621_add_widgets(struct snd_soc_codec *codec)\r
-{\r
-       snd_soc_dapm_new_controls(codec, rt5621_dapm_widgets,\r
-                               ARRAY_SIZE(rt5621_dapm_widgets));\r
-       snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));\r
-       snd_soc_dapm_new_widgets(codec);\r
-\r
-       return 0;\r
-}\r
-\r
-#else\r
-\r
-static int rt5621_pcm_hw_prepare(struct snd_pcm_substream *substream,\r
-               struct snd_soc_dai *codec_dai)\r
-{\r
-\r
-       struct snd_soc_codec *codec = codec_dai->codec;\r
-       int stream = substream->stream;\r
-\r
-       switch (stream)\r
-       {\r
-               case SNDRV_PCM_STREAM_PLAYBACK:\r
-\r
-                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D1_PLAYBACK);   //power on dac to hp and speaker out\r
-                                               \r
-                       rt5621_AudioOutEnable(codec,RT_WAVOUT_SPK,0);   //unmute speaker out\r
-                       \r
-                       rt5621_AudioOutEnable(codec,RT_WAVOUT_HP,0);    //unmute hp out\r
-\r
-                       break;\r
-               case SNDRV_PCM_STREAM_CAPTURE:\r
-\r
-                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D1_RECORD);     //power on input to adc\r
-\r
-                       Enable_ADC_Input_Source(codec,RT_WAVIN_L_MIC1|RT_WAVIN_R_MIC1,1);       //enable record source from mic1\r
-\r
-                       break;                  \r
-       }\r
-       \r
-       return 0;\r
-}\r
-\r
-#endif\r
-/* PLL divisors */\r
-struct _pll_div {\r
-       u32 pll_in;\r
-       u32 pll_out;\r
-       u16 regvalue;\r
-};\r
-\r
-static const struct _pll_div codec_pll_div[] = {\r
-       \r
-       {  2048000,  8192000,   0x0ea0},                \r
-       {  3686400,  8192000,   0x4e27},        \r
-       { 12000000,  8192000,   0x456b},   \r
-       { 13000000,  8192000,   0x495f},\r
-       { 13100000,      8192000,       0x0320},        \r
-       {  2048000,  11289600,  0xf637},\r
-       {  3686400,  11289600,  0x2f22},        \r
-       { 12000000,  11289600,  0x3e2f},   \r
-       { 13000000,  11289600,  0x4d5b},\r
-       { 13100000,      11289600,      0x363b},        \r
-       {  2048000,  16384000,  0x1ea0},\r
-       {  3686400,  16384000,  0x9e27},        \r
-       { 12000000,  16384000,  0x452b},   \r
-       { 13000000,  16384000,  0x542f},\r
-       { 13100000,      16384000,      0x03a0},        \r
-       {  2048000,  16934400,  0xe625},\r
-       {  3686400,  16934400,  0x9126},        \r
-       { 12000000,  16934400,  0x4d2c},   \r
-       { 13000000,  16934400,  0x742f},\r
-       { 13100000,      16934400,      0x3c27},                        \r
-       {  2048000,  22579200,  0x2aa0},\r
-       {  3686400,  22579200,  0x2f20},        \r
-       { 12000000,  22579200,  0x7e2f},   \r
-       { 13000000,  22579200,  0x742f},\r
-       { 13100000,      22579200,      0x3c27},                \r
-       {  2048000,  24576000,  0x2ea0},\r
-       {  3686400,  24576000,  0xee27},        \r
-       { 12000000,  24576000,  0x2915},   \r
-       { 13000000,  24576000,  0x772e},\r
-       { 13100000,      24576000,      0x0d20},        \r
-};\r
-\r
-static const struct _pll_div codec_bclk_pll_div[] = {\r
-\r
-       {  1536000,      24576000,      0x3ea0},        \r
-       {  3072000,      24576000,      0x1ea0},\r
-       {  512000,       24576000,  0x8e90},\r
-       {  256000,   24576000,  0xbe80},\r
-               {  2822400,      11289600,      0x1ee0},        //flove040711\r
-       {  3072000,      12288000,      0x1ee0},        //flove040711   \r
-};\r
-\r
-\r
-static int rt5621_set_dai_pll(struct snd_soc_dai *codec_dai,\r
-               int pll_id, unsigned int freq_in, unsigned int freq_out)\r
-{\r
-       int i;\r
-       int ret = -EINVAL;\r
-       struct snd_soc_codec *codec = codec_dai->codec;\r
-\r
-       if (pll_id < RT5621_PLL_FR_MCLK || pll_id > RT5621_PLL_FR_BCLK)\r
-               return -EINVAL;\r
-\r
-       //rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2, 0x0000,0x1000);        //disable PLL power     \r
-       \r
-       if (!freq_in || !freq_out) {\r
-\r
-               return 0;\r
-       }               \r
-\r
-       if (RT5621_PLL_FR_MCLK == pll_id) {\r
-       for (i = 0; i < ARRAY_SIZE(codec_pll_div); i++) {\r
-                       \r
-               if (codec_pll_div[i].pll_in == freq_in && codec_pll_div[i].pll_out == freq_out)\r
-                       {\r
-                               rt5621_write_mask(codec, RT5621_GLOBAL_CLK_CTRL_REG, 0x0000, 0x4000);                           \r
-                               rt5621_write(codec,RT5621_PLL_CTRL,codec_pll_div[i].regvalue);//set PLL parameter       \r
-                               rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2, 0x1000,0x1000);  //enable PLL power      \r
-                               ret = 0;\r
-                       }\r
-       }\r
-       }\r
-       else if (RT5621_PLL_FR_BCLK == pll_id)\r
-       {\r
-               for (i = 0; i < ARRAY_SIZE(codec_bclk_pll_div); i++)\r
-               {\r
-                       if ((freq_in == codec_bclk_pll_div[i].pll_in) && (freq_out == codec_bclk_pll_div[i].pll_out))\r
-                       {\r
-                               rt5621_write_mask(codec, RT5621_GLOBAL_CLK_CTRL_REG, 0x4000, 0x4000);\r
-                               rt5621_write(codec,RT5621_PLL_CTRL,codec_bclk_pll_div[i].regvalue);//set PLL parameter \r
-                               rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2, 0x1000,0x1000);  //enable PLL power      \r
-                               ret = 0;\r
-                       }\r
-               }\r
-       }\r
-\r
-       rt5621_write_mask(codec,RT5621_GLOBAL_CLK_CTRL_REG,0x8000,0x8000);//Codec sys-clock from PLL    \r
-       return ret;\r
-}\r
-\r
-\r
-struct _coeff_div {\r
-       u32 mclk;\r
-       u32 rate;\r
-       u16 fs;\r
-       u16 regvalue;\r
-};\r
-\r
-/* codec hifi mclk (after PLL) clock divider coefficients */\r
-static const struct _coeff_div coeff_div[] = {\r
-       /* 8k */\r
-       { 8192000,  8000, 256*4, 0x2a2d},\r
-       {12288000,  8000, 384*4, 0x2c2f},\r
-\r
-       /* 11.025k */\r
-       {11289600, 11025, 256*4, 0x2a2d},\r
-       {16934400, 11025, 384*4, 0x2c2f},\r
-\r
-       /* 16k */\r
-       {12288000, 16000, 384*2, 0x1c2f},\r
-       {16384000, 16000, 256*4, 0x2a2d},\r
-       {24576000, 16000, 384*4, 0x2c2f},\r
-\r
-       /* 22.05k */    \r
-       {11289600, 22050, 256*2, 0x1a2d},\r
-       {16934400, 22050, 384*2, 0x1c2f},\r
-\r
-       /* 32k */\r
-       {12288000, 32000, 384  , 0x0c2f},\r
-       {16384000, 32000, 256*2, 0x1a2d},\r
-       {24576000, 32000, 384*2, 0x1c2f},\r
-\r
-       /* 44.1k */\r
-       {11289600, 44100, 256*1, 0x0a2d},\r
-       {22579200, 44100, 256*2, 0x1a2d},\r
-       {45158400, 44100, 256*4, 0x2a2d},       \r
-\r
-       /* 48k */\r
-       {12288000, 48000, 256*1, 0x0a2d},\r
-       {24576000, 48000, 256*2, 0x1a2d},\r
-       {49152000, 48000, 256*4, 0x2a2d},\r
-\r
-};\r
-\r
-\r
-\r
-static int get_coeff(int mclk, int rate)\r
-{\r
-       int i;\r
-       \r
-       printk("get_coeff mclk=%d,rate=%d\n",mclk,rate);\r
-\r
-       for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {\r
-               if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)\r
-                       return i;\r
-       }\r
-       return -EINVAL;\r
-}\r
-\r
-\r
-\r
-\r
-/*\r
- * Clock after PLL and dividers\r
- */\r
- /*in this driver, you have to set sysclk to be 24576000,\r
- * but you don't need to give a clk to be 24576000, our \r
- * internal pll will generate this clock! so it won't make\r
- * you any difficult.\r
- */\r
-static int rt5621_set_dai_sysclk(struct snd_soc_dai *codec_dai,\r
-               int clk_id, unsigned int freq, int dir)\r
-{\r
-       struct snd_soc_codec *codec = codec_dai->codec;\r
-       struct rt5621_priv *rt5621 = codec->private_data;\r
-\r
-       switch (freq) {\r
-       case 24576000:\r
-               rt5621->sysclk = freq;\r
-               return 0;\r
-       }\r
-       return 0;\r
-}\r
-\r
-\r
-static int rt5621_set_dai_fmt(struct snd_soc_dai *codec_dai,\r
-               unsigned int fmt)\r
-{\r
-       struct snd_soc_codec *codec = codec_dai->codec;\r
-       u16 iface = 0;\r
-\r
-       /* set master/slave audio interface */\r
-       switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {\r
-       case SND_SOC_DAIFMT_CBM_CFM:\r
-               iface = 0x0000;\r
-               break;\r
-       case SND_SOC_DAIFMT_CBS_CFS:\r
-               iface = 0x8000;\r
-               break;\r
-       default:\r
-               return -EINVAL;\r
-       }\r
-\r
-       /* interface format */\r
-       switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {\r
-       case SND_SOC_DAIFMT_I2S:\r
-               iface |= 0x0000;\r
-               break;\r
-       case SND_SOC_DAIFMT_RIGHT_J:\r
-               iface |= 0x0001;\r
-               break;\r
-       case SND_SOC_DAIFMT_LEFT_J:\r
-               iface |= 0x0002;\r
-               break;\r
-       case SND_SOC_DAIFMT_DSP_A:\r
-               iface |= 0x0003;\r
-               break;\r
-       case SND_SOC_DAIFMT_DSP_B:\r
-               iface |= 0x4003;\r
-               break;\r
-       default:\r
-               return -EINVAL;\r
-       }\r
-\r
-       /* clock inversion */\r
-       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {\r
-       case SND_SOC_DAIFMT_NB_NF:\r
-               iface |= 0x0000;\r
-               break;\r
-       case SND_SOC_DAIFMT_IB_NF:\r
-               iface |= 0x0100;\r
-               break;\r
-       default:\r
-               return -EINVAL;\r
-       }\r
-\r
-       rt5621_write(codec,RT5621_AUDIO_INTERFACE,iface);\r
-       return 0;\r
-}\r
-\r
-\r
-static int rt5621_pcm_hw_params(struct snd_pcm_substream *substream,\r
-       struct snd_pcm_hw_params *params,\r
-       struct snd_soc_dai *codec_dai)\r
-{\r
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;\r
-       struct snd_soc_device *socdev = rtd->socdev;\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-       struct rt5621_priv *rt5621 = codec->private_data;\r
-       u16 iface=rt5621_read(codec,RT5621_AUDIO_INTERFACE)&0xfff3;\r
-       int coeff = get_coeff(rt5621->sysclk, params_rate(params));\r
-\r
-       printk("rt5621_pcm_hw_params\n");\r
-       if (coeff < 0)\r
-               coeff = get_coeff(24576000, params_rate(params));         /*if not set sysclk, default to be 24.576MHz*/\r
-\r
-       /* bit size */\r
-       switch (params_format(params)) {\r
-       case SNDRV_PCM_FORMAT_S16_LE:\r
-               iface |= 0x0000;\r
-               break;\r
-       case SNDRV_PCM_FORMAT_S20_3LE:\r
-               iface |= 0x0004;\r
-               break;\r
-       case SNDRV_PCM_FORMAT_S24_LE:\r
-               iface |= 0x0008;\r
-               break;\r
-       case SNDRV_PCM_FORMAT_S32_LE:\r
-               iface |= 0x000c;\r
-               break;\r
-       }\r
-\r
-       /* set iface & srate */\r
-       rt5621_write(codec, RT5621_AUDIO_INTERFACE, iface);\r
-\r
-       if (coeff >= 0)\r
-               rt5621_write(codec, RT5621_STEREO_AD_DA_CLK_CTRL, coeff_div[coeff].regvalue);\r
-//     else\r
-//     {\r
-//             printk(KERN_ERR "cant find matched sysclk and rate config\n");\r
-//             return -EINVAL;\r
-               \r
-//     }\r
-       return 0;\r
-}\r
-\r
-#if !USE_DAPM_CONTROL\r
-static int rt5621_set_bias_level(struct snd_soc_codec *codec, \r
-                       enum snd_soc_bias_level level)\r
-{\r
-       switch (level) {\r
-               case SND_SOC_BIAS_ON:\r
-                       break;\r
-               case SND_SOC_BIAS_PREPARE:\r
-                       break;\r
-               case SND_SOC_BIAS_STANDBY:\r
-                       break;\r
-               case SND_SOC_BIAS_OFF:\r
-\r
-                       rt5621_write_mask(codec, 0x02, 0x8080, 0x8080);\r
-                       rt5621_write_mask(codec, 0x04, 0x8080, 0x8080);\r
-                       rt5621_write(codec, 0x3e, 0x0000);\r
-                       rt5621_write(codec, 0x3c, 0x0000);\r
-                       rt5621_write(codec, 0x3a, 0x0000);\r
-                       break;          \r
-       }\r
-       codec->bias_level = level;\r
-       return 0;\r
-}\r
-#else\r
-static int rt5621_set_bias_level(struct snd_soc_codec *codec, \r
-                       enum snd_soc_bias_level level)\r
-{\r
-       switch (level) {\r
-               case SND_SOC_BIAS_ON:\r
-                       break;\r
-               case SND_SOC_BIAS_PREPARE:\r
-                       break;\r
-               case SND_SOC_BIAS_STANDBY:\r
-\r
-                       break;\r
-               case SND_SOC_BIAS_OFF:\r
-\r
-                       rt5621_write_mask(codec, 0x02, 0x8080, 0x8080);\r
-                       rt5621_write_mask(codec, 0x04, 0x8080, 0x8080);\r
-                       rt5621_write(codec, 0x3e, 0x0000);\r
-                       rt5621_write(codec, 0x3c, 0x0000);\r
-                       rt5621_write(codec, 0x3a, 0x0000);\r
-                       break;          \r
-       }\r
-       codec->bias_level = level;\r
-       return 0;\r
-}\r
-#endif\r
-\r
-\r
-\r
-\r
-\r
-#if !USE_DAPM_CONTROL\r
-\r
-static void rt5621_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai)\r
-{\r
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;\r
-       struct snd_soc_device *socdev = rtd->socdev;\r
-       struct snd_soc_codec *codec = socdev->card->codec;\r
-       int stream = substream->stream;\r
-       \r
-       switch (stream)\r
-       {\r
-               case SNDRV_PCM_STREAM_PLAYBACK:\r
-\r
-                       rt5621_AudioOutEnable(codec,RT_WAVOUT_SPK,1);   //mute speaker out\r
-                       \r
-                       rt5621_AudioOutEnable(codec,RT_WAVOUT_HP,1);    //mute hp out\r
-\r
-                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D2_PLAYBACK);   //power off dac to hp and speaker out\r
-                                               \r
-\r
-\r
-                       break;\r
-               case SNDRV_PCM_STREAM_CAPTURE:\r
-\r
-                       Enable_ADC_Input_Source(codec,RT_WAVIN_L_MIC1|RT_WAVIN_R_MIC1,0);       //disable record        source from mic1\r
-\r
-                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D2_RECORD);\r
-                       \r
-\r
-                       break;                  \r
-       }       \r
-}\r
-\r
-#endif\r
-\r
-\r
-#define RT5621_HIFI_RATES SNDRV_PCM_RATE_8000_48000\r
-\r
-#define RT5621_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\\r
-       SNDRV_PCM_FMTBIT_S24_LE)\r
-\r
-struct snd_soc_dai_ops rt5621_hifi_ops = {\r
-       .hw_params = rt5621_pcm_hw_params,      \r
-       .set_fmt = rt5621_set_dai_fmt,\r
-       .set_sysclk = rt5621_set_dai_sysclk,\r
-       .set_pll = rt5621_set_dai_pll,\r
-#if !USE_DAPM_CONTROL\r
-       .prepare = rt5621_pcm_hw_prepare,\r
-       .shutdown = rt5621_shutdown,\r
-#endif\r
-       \r
-};\r
-\r
-struct snd_soc_dai rt5621_dai = { \r
-       \r
-               .name = "RT5621",\r
-               .playback = {\r
-                       .stream_name = "HiFi Playback",\r
-                       .channels_min = 1,\r
-                       .channels_max = 2,\r
-                       .rates = RT5621_HIFI_RATES,\r
-                       .formats = RT5621_FORMATS,},\r
-               .capture = {\r
-                       .stream_name = "HiFi Capture",\r
-                       .channels_min = 1,\r
-                       .channels_max = 2,\r
-                       .rates = RT5621_HIFI_RATES,\r
-                       .formats = RT5621_FORMATS,},\r
-\r
-               .ops = &rt5621_hifi_ops,\r
-};\r
-\r
-\r
-EXPORT_SYMBOL_GPL(rt5621_dai);\r
-\r
-static ssize_t rt5621_index_reg_show(struct device *dev, \r
-       struct device_attribute *attr, char *buf)\r
-{\r
-       struct snd_soc_device *socdev = dev_get_drvdata(dev);\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-       int count = 0;\r
-       int value;\r
-       int i; \r
-       \r
-       count += sprintf(buf, "%s index register\n", codec->name);\r
-\r
-       for (i = 0; i < 0x60; i++) {\r
-               count += sprintf(buf + count, "index-%2x    ", i);\r
-               if (count >= PAGE_SIZE - 1)\r
-                       break;\r
-               value = rt5621_read_index(codec, i);\r
-               count += snprintf(buf + count, PAGE_SIZE - count, "0x%4x", value);\r
-\r
-               if (count >= PAGE_SIZE - 1)\r
-                       break;\r
-\r
-               count += snprintf(buf + count, PAGE_SIZE - count, "\n");\r
-               if (count >= PAGE_SIZE - 1)\r
-                       break;\r
-       }\r
-\r
-       if (count >= PAGE_SIZE)\r
-                       count = PAGE_SIZE - 1;\r
-               \r
-       return count;\r
-       \r
-}\r
-\r
-static DEVICE_ATTR(index_reg, 0444, rt5621_index_reg_show, NULL);\r
-\r
-#if defined(CONFIG_SND_HWDEP)\r
-#if REALTEK_HWDEP\r
-\r
-#define RT_CE_CODEC_HWDEP_NAME "rt56xx hwdep "\r
-\r
-static int rt56xx_hwdep_open(struct snd_hwdep *hw, struct file *file)\r
-{\r
-       printk("enter %s\n", __func__);\r
-       return 0;\r
-}\r
-\r
-static int rt56xx_hwdep_release(struct snd_hwdep *hw, struct file *file)\r
-{\r
-       printk("enter %s\n", __func__);\r
-       return 0;\r
-}\r
-\r
-\r
-static int rt56xx_hwdep_ioctl_common(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)\r
-{\r
-       struct rt56xx_cmd rt56xx;\r
-       struct rt56xx_cmd __user *_rt56xx = arg;\r
-       struct rt56xx_reg_state *buf;\r
-       struct rt56xx_reg_state *p;\r
-       struct snd_soc_codec *codec = hw->private_data;\r
-\r
-       if (copy_from_user(&rt56xx, _rt56xx, sizeof(rt56xx)))\r
-               return -EFAULT;\r
-       buf = kmalloc(sizeof(*buf) * rt56xx.number, GFP_KERNEL);\r
-       if (buf == NULL)\r
-               return -ENOMEM;\r
-       if (copy_from_user(buf, rt56xx.buf, sizeof(*buf) * rt56xx.number)) {\r
-               goto err;\r
-       }\r
-       switch (cmd) {\r
-               case RT_READ_CODEC_REG_IOCTL:\r
-                       for (p = buf; p < buf + rt56xx.number; p++)\r
-                       {\r
-                               p->reg_value = codec->read(codec, p->reg_index);\r
-                       }\r
-                       if (copy_to_user(rt56xx.buf, buf, sizeof(*buf) * rt56xx.number))\r
-                               goto err;\r
-                               \r
-                       break;\r
-               case RT_WRITE_CODEC_REG_IOCTL:\r
-                       for (p = buf; p < buf + rt56xx.number; p++)\r
-                               codec->write(codec, p->reg_index, p->reg_value);\r
-                       break;\r
-       }\r
-\r
-       kfree(buf);\r
-       return 0;\r
-\r
-err:\r
-       kfree(buf);\r
-       return -EFAULT;\r
-       \r
-}\r
-\r
-static int rt56xx_codec_dump_reg(struct snd_hwdep *hw, struct file *file, unsigned long arg)\r
-{\r
-       struct rt56xx_cmd rt56xx;\r
-       struct rt56xx_cmd __user *_rt56xx = arg;\r
-       struct rt56xx_reg_state *buf;\r
-       struct snd_soc_codec *codec = hw->private_data;\r
-       int number = codec->reg_cache_size;\r
-       int i;\r
-\r
-       printk(KERN_DEBUG "enter %s, number = %d\n", __func__, number); \r
-       if (copy_from_user(&rt56xx, _rt56xx, sizeof(rt56xx)))\r
-               return -EFAULT;\r
-       \r
-       buf = kmalloc(sizeof(*buf) * number, GFP_KERNEL);\r
-       if (buf == NULL)\r
-               return -ENOMEM;\r
-\r
-       for (i = 0; i < number; i++)\r
-       {\r
-               buf[i].reg_index = i << 1;\r
-               buf[i].reg_value = codec->read(codec, buf[i].reg_index);\r
-       }\r
-       if (copy_to_user(rt56xx.buf, buf, sizeof(*buf) * i))\r
-               goto err;\r
-       rt56xx.number = number;\r
-       if (copy_to_user(_rt56xx, &rt56xx, sizeof(rt56xx)))\r
-               goto err;\r
-       kfree(buf);\r
-       return 0;\r
-err:\r
-       kfree(buf);\r
-       return -EFAULT;\r
-       \r
-}\r
-\r
-static int rt56xx_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)\r
-{\r
-       if (cmd == RT_READ_ALL_CODEC_REG_IOCTL)\r
-       {\r
-               return rt56xx_codec_dump_reg(hw, file, arg);\r
-       }\r
-       else\r
-       {\r
-               return rt56xx_hwdep_ioctl_common(hw, file, cmd, arg);\r
-       }\r
-}\r
-\r
-static int realtek_ce_init_hwdep(struct snd_soc_codec *codec)\r
-{\r
-       struct snd_hwdep *hw;\r
-       struct snd_card *card = codec->card;\r
-       int err;\r
-\r
-       if ((err = snd_hwdep_new(card, RT_CE_CODEC_HWDEP_NAME, 0, &hw)) < 0)\r
-               return err;\r
-       \r
-       strcpy(hw->name, RT_CE_CODEC_HWDEP_NAME);\r
-       hw->private_data = codec;\r
-       hw->ops.open = rt56xx_hwdep_open;\r
-       hw->ops.release = rt56xx_hwdep_release;\r
-       hw->ops.ioctl = rt56xx_hwdep_ioctl;\r
-       return 0;\r
-}\r
-\r
-#endif\r
-#endif\r
-\r
-static void rt5621_work(struct work_struct *work)\r
-{\r
-       struct snd_soc_codec *codec =\r
-               container_of(work, struct snd_soc_codec, delayed_work.work);\r
-       \r
-       rt5621_set_bias_level(codec, codec->bias_level);\r
-}\r
-\r
-\r
-static int rt5621_suspend(struct platform_device *pdev, pm_message_t state)\r
-{\r
-       struct snd_soc_device *socdev = platform_get_drvdata(pdev);\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-\r
-       /* we only need to suspend if we are a valid card */\r
-       if(!codec->card)\r
-               return 0;\r
-               \r
-       rt5621_set_bias_level(codec, SND_SOC_BIAS_STANDBY);\r
-       return 0;\r
-}\r
-\r
-static int rt5621_resume(struct platform_device *pdev)\r
-{\r
-       struct snd_soc_device *socdev = platform_get_drvdata(pdev);\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-       int i;\r
-       u8 data[3];\r
-       u16 *cache = codec->reg_cache;\r
-\r
-       /* we only need to resume if we are a valid card */\r
-       if(!codec->card)\r
-               return 0;\r
-\r
-       /* Sync reg_cache with the hardware */  \r
-\r
-       for (i = 0; i < ARRAY_SIZE(rt5621_reg); i++) {\r
-               if (i == RT5621_RESET)\r
-                       continue;\r
-               data[0] =i << 1;        \r
-               data[1] = (0xFF00 & cache[i]) >> 8;\r
-               data[2] = 0x00FF & cache[i];    \r
-               codec->hw_write(codec->control_data, data, 3);\r
-       }       \r
-\r
-       rt5621_set_bias_level(codec, SND_SOC_BIAS_STANDBY);\r
-       \r
-       /* charge rt5621 caps */\r
-       \r
-       if (codec->suspend_bias_level == SND_SOC_BIAS_ON) {\r
-               rt5621_set_bias_level(codec, SND_SOC_BIAS_PREPARE);\r
-               codec->bias_level = SND_SOC_BIAS_ON;\r
-               schedule_delayed_work(&codec->delayed_work,\r
-                                       msecs_to_jiffies(caps_charge));\r
-       }\r
-       return 0;\r
-}\r
-\r
-\r
-/*\r
- * initialise the RT5621 driver\r
- * register the mixer and dsp interfaces with the kernel\r
- */\r
-static int rt5621_init(struct snd_soc_device *socdev)\r
-{\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-       int  ret = 0;\r
-\r
-       printk(KERN_INFO "alsa version is 1.0.21, codec driver version is 0.04\n");\r
-       codec->name = "RT5621";\r
-       codec->owner = THIS_MODULE;\r
-       codec->read = rt5621_read;\r
-       codec->write = rt5621_write;\r
-       codec->set_bias_level = rt5621_set_bias_level;\r
-       codec->dai = &rt5621_dai;\r
-       codec->num_dai = 1;\r
-       codec->reg_cache_step = 2;\r
-       codec->reg_cache_size = ARRAY_SIZE(rt5621_reg) * 2;\r
-       codec->reg_cache = kmemdup(rt5621_reg, sizeof(rt5621_reg), GFP_KERNEL);\r
-\r
-       if (codec->reg_cache == NULL)\r
-               return -ENOMEM;\r
-               \r
-       /* register pcms */\r
-       ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);\r
-       if (ret < 0) {\r
-               printk(KERN_ERR "rt5621: failed to create pcms\n");\r
-               goto pcm_err;\r
-       }\r
-\r
-\r
-       rt5621_reset(codec);\r
-       rt5621_write(codec, RT5621_PWR_MANAG_ADD3, 0x8000);//enable Main bias\r
-       rt5621_write(codec, RT5621_PWR_MANAG_ADD2, 0x2000);//enable Vref\r
-\r
-       hp_depop_mode2(codec);\r
-\r
-       rt5621_init_reg(codec);\r
-       rt5621_set_bias_level(codec, SND_SOC_BIAS_PREPARE);\r
-       codec->bias_level = SND_SOC_BIAS_STANDBY;\r
-       schedule_delayed_work(&codec->delayed_work,\r
-               msecs_to_jiffies(caps_charge));\r
-       \r
-       rt5621_add_controls(codec);\r
-\r
-       #if USE_DAPM_CONTROL\r
-\r
-               rt5621_add_widgets(codec);      \r
-\r
-       #endif\r
-\r
-       #if defined(CONFIG_SND_HWDEP)\r
-       #if REALTEK_HWDEP\r
-\r
-               realtek_ce_init_hwdep(codec);\r
-\r
-       #endif\r
-       #endif\r
-\r
-       ret = snd_soc_init_card(socdev);\r
-\r
-       if (ret < 0) {\r
-               printk(KERN_ERR "rt5621: failed to register card\n");\r
-                       goto card_err;\r
-       }\r
-       return ret;\r
-\r
-card_err:\r
-       snd_soc_free_pcms(socdev);\r
-       snd_soc_dapm_free(socdev);\r
-pcm_err:\r
-       kfree(codec->reg_cache);\r
-       return ret;\r
-}\r
-\r
-static int rt5621_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)\r
-{\r
-       struct snd_soc_device *socdev = rt5621_socdev;\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-       int ret;\r
-\r
-       i2c_set_clientdata(i2c, codec);\r
-       codec->control_data = i2c;\r
-\r
-       ret = rt5621_init(socdev);\r
-       if (ret < 0)\r
-               pr_err("failed to initialise rt5621\n");\r
-\r
-       return ret;\r
-}\r
-\r
-\r
-static int rt5621_i2c_remove(struct i2c_client *client)\r
-{\r
-       struct snd_soc_codec *codec = i2c_get_clientdata(client);\r
-       kfree(codec->reg_cache);\r
-       return 0;\r
-}\r
-\r
-static const struct i2c_device_id rt5621_i2c_id[] = {\r
-               {"ALC5621", 0},\r
-               {}\r
-};\r
-MODULE_DEVICE_TABLE(i2c, rt5621_i2c_id);\r
-static struct i2c_driver rt5621_i2c_driver = {\r
-       .driver = {\r
-               .name = "RT5621 I2C Codec",\r
-               .owner = THIS_MODULE,\r
-       },\r
-       .probe =    rt5621_i2c_probe,\r
-       .remove =   rt5621_i2c_remove,\r
-       .id_table = rt5621_i2c_id,\r
-};\r
-\r
-static int rt5621_add_i2c_device(struct platform_device *pdev,\r
-                                const struct rt5621_setup_data *setup)\r
-{\r
-#if 0\r
-       struct i2c_board_info info;\r
-       struct i2c_adapter *adapter;\r
-       struct i2c_client *client;\r
-#endif\r
-       int ret;\r
-       ret = i2c_add_driver(&rt5621_i2c_driver);\r
-       if (ret != 0) {\r
-               dev_err(&pdev->dev, "can't add i2c driver\n");\r
-               return ret;\r
-       }\r
-#if 0\r
-       memset(&info, 0, sizeof(struct i2c_board_info));\r
-       info.addr = setup->i2c_address;\r
-       strlcpy(info.type, "rt5621", I2C_NAME_SIZE);\r
-\r
-       adapter = i2c_get_adapter(setup->i2c_bus);\r
-       if (!adapter) {\r
-               dev_err(&pdev->dev, "can't get i2c adapter %d\n",\r
-                       setup->i2c_bus);\r
-               goto err_driver;\r
-       }\r
-\r
-       client = i2c_new_device(adapter, &info);\r
-       i2c_put_adapter(adapter);\r
-       if (!client) {\r
-               dev_err(&pdev->dev, "can't add i2c device at 0x%x\n",\r
-                       (unsigned int)info.addr);\r
-               goto err_driver;\r
-       }\r
-#endif\r
-       return 0;\r
-\r
-#if 0\r
-err_driver:\r
-       i2c_del_driver(&rt5621_i2c_driver);\r
-       return -ENODEV;\r
-#endif\r
-}\r
-\r
-\r
-static int rt5621_probe(struct platform_device *pdev)\r
-{\r
-       struct snd_soc_device *socdev = platform_get_drvdata(pdev);\r
-       struct rt5621_setup_data *setup = socdev->codec_data;\r
-       struct snd_soc_codec *codec;\r
-       struct rt5621_priv *rt5621;\r
-       int ret;\r
-\r
-       pr_info("RT5621 Audio Codec %s\n", RT5621_VERSION);\r
-\r
-       codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);\r
-       if (codec == NULL)\r
-               return -ENOMEM;\r
-\r
-       rt5621 = kzalloc(sizeof(struct rt5621_priv), GFP_KERNEL);\r
-       if (rt5621 == NULL) {\r
-               kfree(codec);\r
-               return -ENOMEM;\r
-       }\r
-       codec->private_data = rt5621;\r
-       socdev ->card->codec = codec;\r
-       mutex_init(&codec->mutex);\r
-       INIT_LIST_HEAD(&codec->dapm_widgets);\r
-       INIT_LIST_HEAD(&codec->dapm_paths);\r
-       rt5621_socdev = socdev;\r
-       INIT_DELAYED_WORK(&codec->delayed_work, rt5621_work);\r
-       ret = device_create_file(&pdev->dev, &dev_attr_index_reg);\r
-       if (ret < 0)\r
-               printk(KERN_WARNING "asoc: failed to add index_reg sysfs files\n");\r
-\r
-       ret = -ENODEV;\r
-//     if (setup->i2c_address) {\r
-               codec->hw_write = (hw_write_t)i2c_master_send;\r
-               ret = rt5621_add_i2c_device(pdev, setup);\r
-//     }\r
-       if (ret != 0) {\r
-               kfree(codec->private_data);\r
-               kfree(codec);\r
-       }\r
-       return ret;\r
-}\r
-\r
-static int run_delayed_work(struct delayed_work *dwork)\r
-{\r
-       int ret;\r
-\r
-       /* cancel any work waiting to be queued. */\r
-       ret = cancel_delayed_work(dwork);\r
-\r
-       /* if there was any work waiting then we run it now and\r
-        * wait for it's completion */\r
-       if (ret) {\r
-               schedule_delayed_work(dwork, 0);\r
-               flush_scheduled_work();\r
-       }\r
-       return ret;\r
-}\r
-\r
-static int rt5621_remove(struct platform_device *pdev)\r
-{\r
-       struct snd_soc_device *socdev = platform_get_drvdata(pdev);\r
-       struct snd_soc_codec *codec = socdev ->card->codec;\r
-\r
-       if (codec->control_data)\r
-               rt5621_set_bias_level(codec, SND_SOC_BIAS_OFF);\r
-       run_delayed_work(&codec->delayed_work);\r
-       snd_soc_free_pcms(socdev);\r
-       snd_soc_dapm_free(socdev);\r
-       device_remove_file(&pdev->dev, &dev_attr_index_reg);\r
-       i2c_unregister_device(codec->control_data);\r
-       i2c_del_driver(&rt5621_i2c_driver);\r
-       kfree(codec->private_data);\r
-       kfree(codec);\r
-\r
-       return 0;\r
-}\r
-\r
-struct snd_soc_codec_device soc_codec_dev_rt5621 = {\r
-       .probe =        rt5621_probe,\r
-       .remove =       rt5621_remove,\r
-       .suspend =      rt5621_suspend,\r
-       .resume =       rt5621_resume,\r
-};\r
-\r
-EXPORT_SYMBOL_GPL(soc_codec_dev_rt5621);\r
-\r
-static int __init rt5621_modinit(void)\r
-{\r
-       return snd_soc_register_dai(&rt5621_dai);\r
-}\r
-\r
-static void __exit rt5621_exit(void)\r
-{\r
-       snd_soc_unregister_dai(&rt5621_dai);\r
-}\r
-\r
-module_init(rt5621_modinit);\r
-module_exit(rt5621_exit);\r
-MODULE_LICENSE("GPL");\r
-\r
diff --git a/sound/soc/codecs/alc5621.h b/sound/soc/codecs/alc5621.h
deleted file mode 100644 (file)
index bdcebbd..0000000
+++ /dev/null
@@ -1,516 +0,0 @@
-#ifndef _RT5621_H\r
-#define _RT5621_H\r
-\r
-\r
-#define RT5621_RESET                                           0X00                    //RESET CODEC TO DEFAULT\r
-#define RT5621_SPK_OUT_VOL                                     0X02                    //SPEAKER OUT VOLUME\r
-#define RT5621_HP_OUT_VOL                                      0X04                    //HEADPHONE OUTPUT VOLUME\r
-#define RT5621_MONO_AUX_OUT_VOL                                0X06                    //MONO OUTPUT/AUXOUT VOLUME\r
-#define RT5621_AUXIN_VOL                                       0X08                    //AUXIN VOLUME\r
-#define RT5621_LINE_IN_VOL                                     0X0A                    //LINE IN VOLUME\r
-#define RT5621_STEREO_DAC_VOL                          0X0C                    //STEREO DAC VOLUME\r
-#define RT5621_MIC_VOL                                         0X0E                    //MICROPHONE VOLUME\r
-#define RT5621_MIC_ROUTING_CTRL                                0X10                    //MIC ROUTING CONTROL\r
-#define RT5621_ADC_REC_GAIN                                    0X12                    //ADC RECORD GAIN\r
-#define RT5621_ADC_REC_MIXER                           0X14                    //ADC RECORD MIXER CONTROL\r
-#define RT5621_SOFT_VOL_CTRL_TIME                      0X16                    //SOFT VOLUME CONTROL TIME\r
-#define RT5621_OUTPUT_MIXER_CTRL                       0X1C                    //OUTPUT MIXER CONTROL\r
-#define RT5621_MIC_CTRL                                                0X22                    //MICROPHONE CONTROL\r
-#define        RT5621_AUDIO_INTERFACE                          0X34                    //AUDIO INTERFACE\r
-#define RT5621_STEREO_AD_DA_CLK_CTRL           0X36                    //STEREO AD/DA CLOCK CONTROL\r
-#define        RT5621_COMPANDING_CTRL                          0X38                    //COMPANDING CONTROL\r
-#define        RT5621_PWR_MANAG_ADD1                           0X3A                    //POWER MANAGMENT ADDITION 1\r
-#define RT5621_PWR_MANAG_ADD2                          0X3C                    //POWER MANAGMENT ADDITION 2\r
-#define RT5621_PWR_MANAG_ADD3                          0X3E                    //POWER MANAGMENT ADDITION 3\r
-#define RT5621_ADD_CTRL_REG                                    0X40                    //ADDITIONAL CONTROL REGISTER\r
-#define        RT5621_GLOBAL_CLK_CTRL_REG                      0X42                    //GLOBAL CLOCK CONTROL REGISTER\r
-#define RT5621_PLL_CTRL                                                0X44                    //PLL CONTROL\r
-#define RT5621_GPIO_OUTPUT_PIN_CTRL                    0X4A                    //GPIO OUTPUT PIN CONTROL\r
-#define RT5621_GPIO_PIN_CONFIG                         0X4C                    //GPIO PIN CONFIGURATION\r
-#define RT5621_GPIO_PIN_POLARITY                       0X4E                    //GPIO PIN POLARITY/TYPE        \r
-#define RT5621_GPIO_PIN_STICKY                         0X50                    //GPIO PIN STICKY       \r
-#define RT5621_GPIO_PIN_WAKEUP                         0X52                    //GPIO PIN WAKE UP\r
-#define RT5621_GPIO_PIN_STATUS                         0X54                    //GPIO PIN STATUS\r
-#define RT5621_GPIO_PIN_SHARING                                0X56                    //GPIO PIN SHARING\r
-#define        RT5621_OVER_TEMP_CURR_STATUS            0X58                    //OVER TEMPERATURE AND CURRENT STATUS\r
-#define RT5621_JACK_DET_CTRL                           0X5A                    //JACK DETECT CONTROL REGISTER\r
-#define RT5621_MISC_CTRL                                       0X5E                    //MISC CONTROL\r
-#define        RT5621_PSEDUEO_SPATIAL_CTRL                     0X60                    //PSEDUEO STEREO & SPATIAL EFFECT BLOCK CONTROL\r
-#define RT5621_EQ_CTRL                                         0X62                    //EQ CONTROL\r
-#define RT5621_EQ_MODE_ENABLE                          0X66                    //EQ MODE CHANGE ENABLE\r
-#define RT5621_AVC_CTRL                                                0X68                    //AVC CONTROL\r
-#define RT5621_HID_CTRL_INDEX                          0X6A                    //HIDDEN CONTROL INDEX PORT\r
-#define RT5621_HID_CTRL_DATA                           0X6C                    //HIDDEN CONTROL DATA PORT\r
-#define RT5621_VENDOR_ID1                              0x7C                    //VENDOR ID1\r
-#define RT5621_VENDOR_ID2                              0x7E                    //VENDOR ID2\r
-\r
-\r
-//global definition\r
-#define RT_L_MUTE                                              (0x1<<15)               //MUTE LEFT CONTROL BIT\r
-#define RT_L_ZC                                                        (0x1<<14)               //LEFT ZERO CROSS CONTROL BIT\r
-#define RT_L_SM                                                        (0x1<<13)               //LEFT SOFTMUTE CONTROL BIT\r
-#define RT_R_MUTE                                              (0x1<<7)                //MUTE RIGHT CONTROL BIT\r
-#define RT_R_ZC                                                        (0x1<<6)                //RIGHT ZERO CROSS CONTROL BIT\r
-#define RT_R_SM                                                        (0x1<<5)                //RIGHT SOFTMUTE CONTROL BIT\r
-#define RT_M_HP_MIXER                                  (0x1<<15)               //Mute source to HP Mixer\r
-#define RT_M_SPK_MIXER                                 (0x1<<14)               //Mute source to Speaker Mixer\r
-#define RT_M_MONO_MIXER                                        (0x1<<13)               //Mute source to Mono Mixer\r
-#define SPK_CLASS_AB                                           0\r
-#define SPK_CLASS_D                                                    1\r
-\r
-//Mic Routing Control(0x10)\r
-#define M_MIC1_TO_HP_MIXER                             (0x1<<15)               //Mute MIC1 to HP mixer\r
-#define M_MIC1_TO_SPK_MIXER                            (0x1<<14)               //Mute MiC1 to SPK mixer\r
-#define M_MIC1_TO_MONO_MIXER                   (0x1<<13)               //Mute MIC1 to MONO mixer\r
-#define MIC1_DIFF_INPUT_CTRL                   (0x1<<12)               //MIC1 different input control\r
-#define M_MIC2_TO_HP_MIXER                             (0x1<<7)                //Mute MIC2 to HP mixer\r
-#define M_MIC2_TO_SPK_MIXER                            (0x1<<6)                //Mute MiC2 to SPK mixer\r
-#define M_MIC2_TO_MONO_MIXER                   (0x1<<5)                //Mute MIC2 to MONO mixer\r
-#define MIC2_DIFF_INPUT_CTRL                   (0x1<<4)                //MIC2 different input control\r
-\r
-//ADC Record Gain(0x12)\r
-#define M_ADC_L_TO_HP_MIXER                            (0x1<<15)               //Mute left of ADC to HP Mixer\r
-#define M_ADC_R_TO_HP_MIXER                            (0x1<<14)               //Mute right of ADC to HP Mixer\r
-#define M_ADC_L_TO_MONO_MIXER                  (0x1<<13)               //Mute left of ADC to MONO Mixer\r
-#define M_ADC_R_TO_MONO_MIXER                  (0x1<<12)               //Mute right of ADC to MONO Mixer\r
-#define ADC_L_GAIN_MASK                                        (0x1f<<7)               //ADC Record Gain Left channel Mask\r
-#define ADC_L_ZC_DET                                   (0x1<<6)                //ADC Zero-Cross Detector Control\r
-#define ADC_R_ZC_DET                                   (0x1<<5)                //ADC Zero-Cross Detector Control\r
-#define ADC_R_GAIN_MASK                                        (0x1f<<0)               //ADC Record Gain Right channel Mask\r
-\r
-//ADC Input Mixer Control(0x14)\r
-#define M_MIC1_TO_ADC_L_MIXER                          (0x1<<14)               //Mute mic1 to left channel of ADC mixer\r
-#define M_MIC2_TO_ADC_L_MIXER                          (0x1<<13)               //Mute mic2 to left channel of ADC mixer\r
-#define M_LINEIN_L_TO_ADC_L_MIXER                      (0x1<<12)               //Mute line In left channel to left channel of ADC mixer\r
-#define M_AUXIN_L_TO_ADC_L_MIXER                       (0x1<<11)               //Mute aux In left channel to left channel of ADC mixer\r
-#define M_HPMIXER_L_TO_ADC_L_MIXER                     (0x1<<10)               //Mute HP mixer left channel to left channel of ADC mixer\r
-#define M_SPKMIXER_L_TO_ADC_L_MIXER                    (0x1<<9)                //Mute SPK mixer left channel to left channel of ADC mixer\r
-#define M_MONOMIXER_L_TO_ADC_L_MIXER           (0x1<<8)                //Mute MONO mixer left channel to left channel of ADC mixer\r
-#define M_MIC1_TO_ADC_R_MIXER                          (0x1<<6)                //Mute mic1 to right channel of ADC mixer\r
-#define M_MIC2_TO_ADC_R_MIXER                          (0x1<<5)                //Mute mic2 to right channel of ADC mixer\r
-#define M_LINEIN_R_TO_ADC_R_MIXER                      (0x1<<4)                //Mute lineIn right channel to right channel of ADC mixer\r
-#define M_AUXIN_R_TO_ADC_R_MIXER                       (0x1<<3)                //Mute aux In right channel to right channel of ADC mixer\r
-#define M_HPMIXER_R_TO_ADC_R_MIXER                     (0x1<<2)                //Mute HP mixer right channel to right channel of ADC mixer\r
-#define M_SPKMIXER_R_TO_ADC_R_MIXER                    (0x1<<1)                //Mute SPK mixer right channel to right channel of ADC mixer\r
-#define M_MONOMIXER_R_TO_ADC_R_MIXER           (0x1<<0)                //Mute MONO mixer right channel to right channel of ADC mixer\r
-\r
-//Output Mixer Control(0x1C)\r
-#define        SPKOUT_N_SOUR_MASK                                      (0x3<<14)       \r
-#define        SPKOUT_N_SOUR_LN                                        (0x2<<14)\r
-#define        SPKOUT_N_SOUR_RP                                        (0x1<<14)\r
-#define        SPKOUT_N_SOUR_RN                                        (0x0<<14)\r
-#define SPK_OUTPUT_CLASS_AB                                    (0x0<<13)\r
-#define SPK_OUTPUT_CLASS_D                                     (0x1<<13)\r
-#define SPK_CLASS_AB_S_AMP                                     (0x0<<12)\r
-#define SPK_CALSS_AB_W_AMP                                     (0x1<<12)\r
-#define SPKOUT_INPUT_SEL_MASK                          (0x3<<10)\r
-#define SPKOUT_INPUT_SEL_MONOMIXER                     (0x3<<10)\r
-#define SPKOUT_INPUT_SEL_SPKMIXER                      (0x2<<10)\r
-#define SPKOUT_INPUT_SEL_HPMIXER                       (0x1<<10)\r
-#define SPKOUT_INPUT_SEL_VMID                          (0x0<<10)\r
-#define HPL_INPUT_SEL_HPLMIXER                         (0x1<<9)\r
-#define HPR_INPUT_SEL_HPRMIXER                         (0x1<<8)        \r
-#define MONO_AUX_INPUT_SEL_MASK                                (0x3<<6)\r
-#define MONO_AUX_INPUT_SEL_MONO                                (0x3<<6)\r
-#define MONO_AUX_INPUT_SEL_SPK                         (0x2<<6)\r
-#define MONO_AUX_INPUT_SEL_HP                          (0x1<<6)\r
-#define MONO_AUX_INPUT_SEL_VMID                                (0x0<<6)\r
-\r
-//Micphone Control define(0x22)\r
-#define MIC1           1\r
-#define MIC2           2\r
-#define MIC_BIAS_90_PRECNET_AVDD       1\r
-#define        MIC_BIAS_75_PRECNET_AVDD        2\r
-\r
-#define MIC1_BOOST_CTRL_MASK           (0x3<<10)\r
-#define MIC1_BOOST_CTRL_BYPASS         (0x0<<10)\r
-#define MIC1_BOOST_CTRL_20DB           (0x1<<10)\r
-#define MIC1_BOOST_CTRL_30DB           (0x2<<10)\r
-#define MIC1_BOOST_CTRL_40DB           (0x3<<10)\r
-\r
-#define MIC2_BOOST_CTRL_MASK           (0x3<<8)\r
-#define MIC2_BOOST_CTRL_BYPASS         (0x0<<8)\r
-#define MIC2_BOOST_CTRL_20DB           (0x1<<8)\r
-#define MIC2_BOOST_CTRL_30DB           (0x2<<8)\r
-#define MIC2_BOOST_CTRL_40DB           (0x3<<8)\r
-\r
-#define MICBIAS_VOLT_CTRL_MASK         (0x1<<5)\r
-#define MICBIAS_VOLT_CTRL_90P          (0x0<<5)\r
-#define MICBIAS_VOLT_CTRL_75P          (0x1<<5)\r
-\r
-#define MICBIAS_SHORT_CURR_DET_MASK            (0x3)\r
-#define MICBIAS_SHORT_CURR_DET_600UA   (0x0)\r
-#define MICBIAS_SHORT_CURR_DET_1200UA  (0x1)\r
-#define MICBIAS_SHORT_CURR_DET_1800UA  (0x2)\r
-\r
-//Audio Interface(0x34)                        \r
-#define SDP_MASTER_MODE                                (0x0<<15)               //Main I2S interface select Master mode\r
-#define SDP_SLAVE_MODE                         (0x1<<15)               //Main I2S interface select Slave mode\r
-#define I2S_PCM_MODE                           (0x1<<14)               //PCM           0:mode A                                ,1:mode B                                                                                                       \r
-#define MAIN_I2S_BCLK_POL_CTRL         (0x1<<7)                //0:Normal 1:Invert\r
-#define ADC_DATA_L_R_SWAP                      (0x1<<5)                //0:ADC data appear at left phase of LRCK\r
-                                                                                                       //1:ADC data appear at right phase of LRCK\r
-#define DAC_DATA_L_R_SWAP                      (0x1<<4)                //0:DAC data appear at left phase of LRCK\r
-                                                                                                       //1:DAC data appear at right phase of LRCK      \r
-//Data Length Slection\r
-#define I2S_DL_MASK                            (0x3<<2)                //main i2s Data Length mask     \r
-#define I2S_DL_16                              (0x0<<2)                //16 bits\r
-#define I2S_DL_20                              (0x1<<2)                //20 bits\r
-#define        I2S_DL_24                               (0x2<<2)                //24 bits\r
-#define I2S_DL_32                              (0x3<<2)                //32 bits\r
-                                                                                                       \r
-//PCM Data Format Selection\r
-#define I2S_DF_MASK                            (0x3)                   //main i2s Data Format mask\r
-#define I2S_DF_I2S                             (0x0)                   //I2S FORMAT \r
-#define I2S_DF_RIGHT                   (0x1)                   //RIGHT JUSTIFIED format\r
-#define        I2S_DF_LEFT                             (0x2)                   //LEFT JUSTIFIED  format\r
-#define I2S_DF_PCM                             (0x3)                   //PCM format\r
-\r
-//Stereo AD/DA Clock Control(0x36h)\r
-#define I2S_PRE_DIV_MASK               (0x7<<12)                       \r
-#define I2S_PRE_DIV_1                  (0x0<<12)                       //DIV 1\r
-#define I2S_PRE_DIV_2                  (0x1<<12)                       //DIV 2\r
-#define I2S_PRE_DIV_4                  (0x2<<12)                       //DIV 4\r
-#define I2S_PRE_DIV_8                  (0x3<<12)                       //DIV 8\r
-#define I2S_PRE_DIV_16                 (0x4<<12)                       //DIV 16\r
-#define I2S_PRE_DIV_32                 (0x5<<12)                       //DIV 32\r
-\r
-#define I2S_SCLK_DIV_MASK              (0x7<<9)                        \r
-#define I2S_SCLK_DIV_1                 (0x0<<9)                        //DIV 1\r
-#define I2S_SCLK_DIV_2                 (0x1<<9)                        //DIV 2\r
-#define I2S_SCLK_DIV_3                 (0x2<<9)                        //DIV 3\r
-#define I2S_SCLK_DIV_4                 (0x3<<9)                        //DIV 4\r
-#define I2S_SCLK_DIV_6                 (0x4<<9)                        //DIV 6\r
-#define I2S_SCLK_DIV_8                 (0x5<<9)                        //DIV 8\r
-#define I2S_SCLK_DIV_12                        (0x6<<9)                        //DIV 12\r
-#define I2S_SCLK_DIV_16                        (0x7<<9)                        //DIV 16\r
-\r
-#define I2S_WCLK_DIV_PRE_MASK          (0xF<<5)                        \r
-#define I2S_WCLK_PRE_DIV_1                     (0x0<<5)                        //DIV 1\r
-#define I2S_WCLK_PRE_DIV_2                     (0x1<<5)                        //DIV 2\r
-#define I2S_WCLK_PRE_DIV_3                     (0x2<<5)                        //DIV 3\r
-#define I2S_WCLK_PRE_DIV_4                     (0x3<<5)                        //DIV 4\r
-#define I2S_WCLK_PRE_DIV_5                     (0x4<<5)                        //DIV 5\r
-#define I2S_WCLK_PRE_DIV_6                     (0x5<<5)                        //DIV 6\r
-#define I2S_WCLK_PRE_DIV_7                     (0x6<<5)                        //DIV 7\r
-#define I2S_WCLK_PRE_DIV_8                     (0x7<<5)                        //DIV 8\r
-//........................\r
-\r
-#define I2S_WCLK_DIV_MASK              (0x7<<2)                        \r
-#define I2S_WCLK_DIV_2                 (0x0<<2)                        //DIV 2\r
-#define I2S_WCLK_DIV_4                 (0x1<<2)                        //DIV 4\r
-#define I2S_WCLK_DIV_8                 (0x2<<2)                        //DIV 8\r
-#define I2S_WCLK_DIV_16                        (0x3<<2)                        //DIV 16\r
-#define I2S_WCLK_DIV_32                        (0x4<<2)                        //DIV 32\r
-\r
-#define ADDA_FILTER_CLK_SEL_256FS      (0<<1)                  //256FS\r
-#define ADDA_FILTER_CLK_SEL_384FS      (1<<1)                  //384FS\r
-\r
-#define ADDA_OSR_SEL_64FS      (0)                                             //64FS\r
-#define ADDA_OSR_SEL_128FS     (1)                                             //128FS\r
-\r
-//Power managment addition 1 (0x3A),0:Disable,1:Enable\r
-#define PWR_MAIN_I2S_EN                                (0x1<<15)\r
-#define PWR_ZC_DET_PD_EN                       (0x1<<14)       \r
-#define PWR_MIC1_BIAS_EN                       (0x1<<11)\r
-#define PWR_SHORT_CURR_DET_EN          (0x1<<10)\r
-#define PWR_SOFTGEN_EN                         (0x1<<8)\r
-#define        PWR_DEPOP_BUF_HP                        (0x1<<6)\r
-#define        PWR_HP_OUT_AMP                          (0x1<<5)\r
-#define        PWR_HP_OUT_ENH_AMP                      (0x1<<4)\r
-#define PWR_DEPOP_BUF_AUX                      (0x1<<2)\r
-#define PWR_AUX_OUT_AMP                                (0x1<<1)\r
-#define PWR_AUX_OUT_ENH_AMP                    (0x1)\r
-\r
-\r
-//Power managment addition 2(0x3C),0:Disable,1:Enable\r
-#define PWR_CLASS_AB                           (0x1<<15)\r
-#define PWR_CLASS_D                                    (0x1<<14)\r
-#define PWR_VREF                                       (0x1<<13)\r
-#define PWR_PLL                                                (0x1<<12)\r
-#define PWR_DAC_REF_CIR                                (0x1<<10)\r
-#define PWR_L_DAC_CLK                          (0x1<<9)\r
-#define PWR_R_DAC_CLK                          (0x1<<8)\r
-#define PWR_L_ADC_CLK_GAIN                     (0x1<<7)\r
-#define PWR_R_ADC_CLK_GAIN                     (0x1<<6)\r
-#define PWR_L_HP_MIXER                         (0x1<<5)\r
-#define PWR_R_HP_MIXER                         (0x1<<4)\r
-#define PWR_SPK_MIXER                          (0x1<<3)\r
-#define PWR_MONO_MIXER                         (0x1<<2)\r
-#define PWR_L_ADC_REC_MIXER                    (0x1<<1)\r
-#define PWR_R_ADC_REC_MIXER                    (0x1)\r
-\r
-//Power managment addition 3(0x3E),0:Disable,1:Enable\r
-#define PWR_MAIN_BIAS                          (0x1<<15)\r
-#define PWR_AUXOUT_L_VOL_AMP           (0x1<<14)\r
-#define PWR_AUXOUT_R_VOL_AMP           (0x1<<13)\r
-#define PWR_SPK_OUT                                    (0x1<<12)\r
-#define PWR_HP_L_OUT_VOL                       (0x1<<10)\r
-#define PWR_HP_R_OUT_VOL                       (0x1<<9)\r
-#define PWR_LINEIN_L_VOL                       (0x1<<7)\r
-#define PWR_LINEIN_R_VOL                       (0x1<<6)\r
-#define PWR_AUXIN_L_VOL                                (0x1<<5)\r
-#define PWR_AUXIN_R_VOL                                (0x1<<4)\r
-#define PWR_MIC1_FUN_CTRL                      (0x1<<3)\r
-#define PWR_MIC2_FUN_CTRL                      (0x1<<2)\r
-#define PWR_MIC1_BOOST_MIXER           (0x1<<1)\r
-#define PWR_MIC2_BOOST_MIXER           (0x1)\r
-\r
-\r
-//Additional Control Register(0x40)\r
-#define AUXOUT_SEL_DIFF                                        (0x1<<15)       //Differential Mode\r
-#define AUXOUT_SEL_SE                                  (0x1<<15)       //Single-End Mode\r
-\r
-#define SPK_AB_AMP_CTRL_MASK                   (0x7<<12)\r
-#define SPK_AB_AMP_CTRL_RATIO_225              (0x0<<12)               //2.25 Vdd\r
-#define SPK_AB_AMP_CTRL_RATIO_200              (0x1<<12)               //2.00 Vdd\r
-#define SPK_AB_AMP_CTRL_RATIO_175              (0x2<<12)               //1.75 Vdd\r
-#define SPK_AB_AMP_CTRL_RATIO_150              (0x3<<12)               //1.50 Vdd\r
-#define SPK_AB_AMP_CTRL_RATIO_125              (0x4<<12)               //1.25 Vdd      \r
-#define SPK_AB_AMP_CTRL_RATIO_100              (0x5<<12)               //1.00 Vdd\r
-\r
-#define SPK_D_AMP_CTRL_MASK                            (0x3<<10)\r
-#define SPK_D_AMP_CTRL_RATIO_175               (0x0<<10)               //1.75 Vdd\r
-#define SPK_D_AMP_CTRL_RATIO_150               (0x1<<10)               //1.50 Vdd      \r
-#define SPK_D_AMP_CTRL_RATIO_125               (0x2<<10)               //1.25 Vdd\r
-#define SPK_D_AMP_CTRL_RATIO_100               (0x3<<10)               //1.00 Vdd\r
-\r
-#define STEREO_DAC_HI_PASS_FILTER_EN   (0x1<<9)                //Stereo DAC high pass filter enable\r
-#define STEREO_ADC_HI_PASS_FILTER_EN   (0x1<<8)                //Stereo ADC high pass filter enable\r
-\r
-#define DIG_VOL_BOOST_MASK                             (0x3<<4)                //Digital volume Boost mask\r
-#define DIG_VOL_BOOST_0DB                              (0x0<<4)                //Digital volume Boost 0DB\r
-#define DIG_VOL_BOOST_6DB                              (0x1<<4)                //Digital volume Boost 6DB\r
-#define DIG_VOL_BOOST_12DB                             (0x2<<4)                //Digital volume Boost 12DB\r
-#define DIG_VOL_BOOST_18DB                             (0x3<<4)                //Digital volume Boost 18DB\r
-\r
-\r
-//Global Clock Control Register(0x42)\r
-#define SYSCLK_SOUR_SEL_MASK                   (0x1<<15)\r
-#define SYSCLK_SOUR_SEL_MCLK                   (0x0<<15)               //system Clock source from MCLK\r
-#define SYSCLK_SOUR_SEL_PLL                            (0x1<<15)               //system Clock source from PLL\r
-#define PLLCLK_SOUR_SEL_MCLK                   (0x0<<14)               //PLL clock source from MCLK\r
-#define PLLCLK_SOUR_SEL_BITCLK                 (0x1<<14)               //PLL clock source from BITCLK\r
-\r
-#define PLLCLK_DIV_RATIO_MASK                  (0x3<<1)                \r
-#define PLLCLK_DIV_RATIO_DIV1                  (0x0<<1)                //DIV 1\r
-#define PLLCLK_DIV_RATIO_DIV2                  (0x1<<1)                //DIV 2\r
-#define PLLCLK_DIV_RATIO_DIV4                  (0x2<<1)                //DIV 4\r
-#define PLLCLK_DIV_RATIO_DIV8                  (0x3<<1)                //DIV 8\r
-\r
-#define PLLCLK_PRE_DIV1                                        (0x0)                   //DIV 1\r
-#define PLLCLK_PRE_DIV2                                        (0x1)                   //DIV 2\r
-\r
-//PLL Control(0x44)\r
-\r
-#define PLL_CTRL_M_VAL(m)              ((m)&0xf)\r
-#define PLL_CTRL_K_VAL(k)              (((k)&0x7)<<4)\r
-#define PLL_CTRL_N_VAL(n)              (((n)&0xff)<<8)\r
-\r
-//GPIO Pin Configuration(0x4C)\r
-#define GPIO_PIN_MASK                          (0x1<<1)\r
-#define GPIO_PIN_SET_INPUT                     (0x1<<1)\r
-#define GPIO_PIN_SET_OUTPUT                    (0x0<<1)\r
-\r
-//Pin Sharing(0x56)\r
-#define LINEIN_L_PIN_SHARING           (0x1<<15)\r
-#define LINEIN_L_PIN_AS_LINEIN_L       (0x0<<15)\r
-#define LINEIN_L_PIN_AS_JD1                    (0x1<<15)\r
-\r
-#define LINEIN_R_PIN_SHARING           (0x1<<14)\r
-#define LINEIN_R_PIN_AS_LINEIN_R       (0x0<<14)\r
-#define LINEIN_R_PIN_AS_JD2                    (0x1<<14)\r
-\r
-#define GPIO_PIN_SHARING                       (0x3)\r
-#define GPIO_PIN_AS_GPIO                       (0x0)\r
-#define GPIO_PIN_AS_IRQOUT                     (0x1)\r
-#define GPIO_PIN_AS_PLLOUT                     (0x3)\r
-\r
-//Jack Detect Control Register(0x5A)\r
-#define JACK_DETECT_MASK                       (0x3<<14)\r
-#define JACK_DETECT_USE_JD2                    (0x3<<14)\r
-#define JACK_DETECT_USE_JD1                    (0x2<<14)\r
-#define JACK_DETECT_USE_GPIO           (0x1<<14)\r
-#define JACK_DETECT_OFF                                (0x0<<14)\r
-\r
-#define        SPK_EN_IN_HI                            (0x1<<11)\r
-#define AUX_R_EN_IN_HI                         (0x1<<10)\r
-#define AUX_L_EN_IN_HI                         (0x1<<9)\r
-#define HP_EN_IN_HI                                    (0x1<<8)\r
-#define        SPK_EN_IN_LO                            (0x1<<7)\r
-#define AUX_R_EN_IN_LO                         (0x1<<6)\r
-#define AUX_L_EN_IN_LO                         (0x1<<5)\r
-#define HP_EN_IN_LO                                    (0x1<<4)\r
-\r
-////MISC CONTROL(0x5E)\r
-#define DISABLE_FAST_VREG                      (0x1<<15)\r
-#define SPK_CLASS_AB_OC_PD                     (0x1<<13)\r
-#define SPK_CLASS_AB_OC_DET                    (0x1<<12)\r
-#define HP_DEPOP_MODE3_EN                      (0x1<<10)\r
-#define HP_DEPOP_MODE2_EN                      (0x1<<9)\r
-#define HP_DEPOP_MODE1_EN                      (0x1<<8)\r
-#define AUXOUT_DEPOP_MODE3_EN          (0x1<<6)\r
-#define AUXOUT_DEPOP_MODE2_EN          (0x1<<5)\r
-#define AUXOUT_DEPOP_MODE1_EN          (0x1<<4)\r
-#define M_DAC_L_INPUT                          (0x1<<3)\r
-#define M_DAC_R_INPUT                          (0x1<<2)\r
-#define IRQOUT_INV_CTRL                                (0x1<<0)\r
-\r
-//Psedueo Stereo & Spatial Effect Block Control(0x60)\r
-#define SPATIAL_CTRL_EN                                (0x1<<15)\r
-#define ALL_PASS_FILTER_EN                     (0x1<<14)\r
-#define PSEUDO_STEREO_EN                       (0x1<<13)\r
-#define STEREO_EXPENSION_EN                    (0x1<<12)\r
-\r
-#define GAIN_3D_PARA_L_MASK                    (0x7<<9)\r
-#define GAIN_3D_PARA_L_1_00                    (0x0<<9)\r
-#define GAIN_3D_PARA_L_1_25                    (0x1<<9)\r
-#define GAIN_3D_PARA_L_1_50                    (0x2<<9)\r
-#define GAIN_3D_PARA_L_1_75                    (0x3<<9)\r
-#define GAIN_3D_PARA_L_2_00                    (0x4<<9)\r
-\r
-#define GAIN_3D_PARA_R_MASK                    (0x7<<6)\r
-#define GAIN_3D_PARA_R_1_00                    (0x0<<6)\r
-#define GAIN_3D_PARA_R_1_25                    (0x1<<6)\r
-#define GAIN_3D_PARA_R_1_50                    (0x2<<6)\r
-#define GAIN_3D_PARA_R_1_75                    (0x3<<6)\r
-#define GAIN_3D_PARA_R_2_00                    (0x4<<6)\r
-\r
-#define RATIO_3D_L_MASK                                (0x3<<4)\r
-#define RATIO_3D_L_0_0                         (0x0<<4)\r
-#define RATIO_3D_L_0_66                                (0x1<<4)\r
-#define RATIO_3D_L_1_0                         (0x2<<4)\r
-\r
-#define RATIO_3D_R_MASK                                (0x3<<2)\r
-#define RATIO_3D_R_0_0                         (0x0<<2)\r
-#define RATIO_3D_R_0_66                                (0x1<<2)\r
-#define RATIO_3D_R_1_0                         (0x2<<2)\r
-\r
-#define APF_MASK                                       (0x3)\r
-#define APF_FOR_48K                                    (0x3)\r
-#define APF_FOR_44_1K                          (0x2)\r
-#define APF_FOR_32K                                    (0x1)\r
-\r
-//EQ CONTROL(0x62)\r
-\r
-#define EN_HW_EQ_BLK                   (0x1<<15)               //HW EQ block control\r
-#define EN_HW_EQ_HPF_MODE              (0x1<<14)               //High Frequency shelving filter mode\r
-#define EN_HW_EQ_SOUR                  (0x1<<11)               //0:DAC PATH,1:ADC PATH\r
-#define EN_HW_EQ_HPF                   (0x1<<4)                //EQ High Pass Filter Control\r
-#define EN_HW_EQ_BP3                   (0x1<<3)                //EQ Band-3 Control\r
-#define EN_HW_EQ_BP2                   (0x1<<2)                //EQ Band-2 Control\r
-#define EN_HW_EQ_BP1                   (0x1<<1)                //EQ Band-1 Control\r
-#define EN_HW_EQ_LPF                   (0x1<<0)                //EQ Low Pass Filter Control\r
-\r
-//EQ Mode Change Enable(0x66)\r
-#define EQ_HPF_CHANGE_EN               (0x1<<4)                //EQ High Pass Filter Mode Change Enable\r
-#define EQ_BP3_CHANGE_EN               (0x1<<3)                //EQ Band-3 Pass Filter Mode Change Enable\r
-#define EQ_BP2_CHANGE_EN               (0x1<<2)                //EQ Band-2 Pass Filter Mode Change Enable\r
-#define EQ_BP1_CHANGE_EN               (0x1<<1)                //EQ Band-1 Pass Filter Mode Change Enable\r
-#define EQ_LPF_CHANGE_EN               (0x1<<0)                //EQ Low Pass Filter Mode Change Enable\r
-\r
-\r
-//AVC Control(0x68)\r
-#define AVC_ENABLE                             (0x1<<15)\r
-#define AVC_TARTGET_SEL_MASK   (0x1<<14)\r
-#define        AVC_TARTGET_SEL_R               (0x1<<14)\r
-#define        AVC_TARTGET_SEL_L               (0x0<<14)\r
-\r
-\r
-struct rt5621_setup_data {\r
-       unsigned short i2c_address;\r
-       unsigned short i2c_bus;\r
-};\r
-\r
-\r
-\r
-#define RT5621_PLL_FR_MCLK                     0\r
-#define RT5621_PLL_FR_BCLK                     1\r
-\r
-\r
-#define USE_DAPM_CONTROL 0\r
-#define REALTEK_HWDEP 0\r
-\r
-//WaveOut channel for realtek codec\r
-enum \r
-{\r
-       RT_WAVOUT_SPK                           =(0x1<<0),\r
-       RT_WAVOUT_SPK_R                         =(0x1<<1),\r
-       RT_WAVOUT_SPK_L                         =(0x1<<2),\r
-       RT_WAVOUT_HP                            =(0x1<<3),\r
-       RT_WAVOUT_HP_R                          =(0x1<<4),\r
-       RT_WAVOUT_HP_L                          =(0x1<<5),      \r
-       RT_WAVOUT_MONO                          =(0x1<<6),\r
-       RT_WAVOUT_AUXOUT                        =(0x1<<7),\r
-       RT_WAVOUT_AUXOUT_R                      =(0x1<<8),\r
-       RT_WAVOUT_AUXOUT_L                      =(0x1<<9),\r
-       RT_WAVOUT_LINEOUT                       =(0x1<<10),\r
-       RT_WAVOUT_LINEOUT_R                     =(0x1<<11),\r
-       RT_WAVOUT_LINEOUT_L                     =(0x1<<12),     \r
-       RT_WAVOUT_DAC                           =(0x1<<13),             \r
-       RT_WAVOUT_ALL_ON                        =(0x1<<14),\r
-};\r
-\r
-//WaveIn channel for realtek codec\r
-enum\r
-{\r
-       RT_WAVIN_R_MONO_MIXER           =(0x1<<0),\r
-       RT_WAVIN_R_SPK_MIXER            =(0x1<<1),\r
-       RT_WAVIN_R_HP_MIXER                     =(0x1<<2),\r
-       RT_WAVIN_R_PHONE                        =(0x1<<3),\r
-       RT_WAVIN_R_AUXIN                        =(0x1<<3),      \r
-       RT_WAVIN_R_LINE_IN                      =(0x1<<4),\r
-       RT_WAVIN_R_MIC2                         =(0x1<<5),\r
-       RT_WAVIN_R_MIC1                         =(0x1<<6),\r
-\r
-       RT_WAVIN_L_MONO_MIXER           =(0x1<<8),\r
-       RT_WAVIN_L_SPK_MIXER            =(0x1<<9),\r
-       RT_WAVIN_L_HP_MIXER                     =(0x1<<10),\r
-       RT_WAVIN_L_PHONE                        =(0x1<<11),\r
-       RT_WAVIN_L_AUXIN                        =(0x1<<11),\r
-       RT_WAVIN_L_LINE_IN                      =(0x1<<12),\r
-       RT_WAVIN_L_MIC2                         =(0x1<<13),\r
-       RT_WAVIN_L_MIC1                         =(0x1<<14),\r
-};\r
-\r
-enum \r
-{\r
-       POWER_STATE_D0=0,\r
-       POWER_STATE_D1,\r
-       POWER_STATE_D1_PLAYBACK,\r
-       POWER_STATE_D1_RECORD,\r
-       POWER_STATE_D2,\r
-       POWER_STATE_D2_PLAYBACK,\r
-       POWER_STATE_D2_RECORD,\r
-       POWER_STATE_D3,\r
-       POWER_STATE_D4\r
-\r
-}; \r
-\r
-#if REALTEK_HWDEP\r
-\r
-struct rt56xx_reg_state\r
-{\r
-       unsigned int reg_index;\r
-       unsigned int reg_value;\r
-};\r
-\r
-struct rt56xx_cmd\r
-{\r
-       size_t number;\r
-       struct rt56xx_reg_state __user *buf;            \r
-};\r
-\r
-enum \r
-{\r
-       RT_READ_CODEC_REG_IOCTL = _IOR('R', 0x01, struct rt56xx_cmd),\r
-       RT_READ_ALL_CODEC_REG_IOCTL = _IOR('R', 0x02, struct rt56xx_cmd),\r
-       RT_WRITE_CODEC_REG_IOCTL = _IOW('R', 0x03, struct rt56xx_cmd),\r
-};\r
-\r
-#endif\r
-\r
-extern struct snd_soc_dai rt5621_dai;  \r
-extern struct snd_soc_codec_device soc_codec_dev_rt5621;\r
-\r
-#endif\r
diff --git a/sound/soc/codecs/rt5621.c b/sound/soc/codecs/rt5621.c
new file mode 100644 (file)
index 0000000..c0ee91b
--- /dev/null
@@ -0,0 +1,1221 @@
+/*
+ * rt5621.c  --  RT5621 ALSA SoC audio codec driver
+ *
+ * Copyright 2011 Realtek Semiconductor Corp.
+ * Author: Johnny Hsu <johnnyhsu@realtek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+#include <sound/tlv.h>
+
+#include "rt5621.h"
+
+#if REALTEK_HWDEP
+#include <linux/ioctl.h>
+#include <linux/types.h>
+#endif
+
+#if 0
+#define DBG(x...)      printk(x)
+#else
+#define DBG(x...)
+#endif
+
+#define RT5621_VERSION "0.01 alsa 1.0.24"
+
+static int caps_charge = 500;
+module_param(caps_charge, int, 0);
+MODULE_PARM_DESC(caps_charge, "RT5621 cap charge time (msecs)");
+
+struct snd_soc_codec *rt5621_codec;
+
+static void rt5621_work(struct work_struct *work);
+
+static struct workqueue_struct *rt5621_workq;
+static DECLARE_DELAYED_WORK(delayed_work, rt5621_work);
+
+#define ENABLE_EQ_HREQ 1
+
+struct rt5621_priv {
+       unsigned int sysclk;
+};
+
+enum {
+       NORMAL,
+       CLUB,
+       DANCE,
+       LIVE,
+       POP,
+       ROCK,
+       OPPO,
+       TREBLE,
+       BASS,
+       HFREQ,  
+       EQTEST,
+       SPK_FR  
+};
+
+typedef struct  _HW_EQ_PRESET
+{
+       u16     HwEqType;
+       u16     EqValue[14];
+       u16     HwEQCtrl;
+
+}HW_EQ_PRESET;
+
+HW_EQ_PRESET HwEq_Preset[]={
+       /* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x 0x9 0xa 0x 0xc 0x62*/
+       {NORMAL,{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},0x0000},                   
+       {CLUB  ,{0x1C10,0x0000,0xC1CC,0x1E5D,0x0699,0xCD48,0x188D,0x0699,0xC3B6,0x1CD0,0x0699,0x0436,0x0000},0x800E},
+       {DANCE ,{0x1F2C,0x095B,0xC071,0x1F95,0x0616,0xC96E,0x1B11,0xFC91,0xDCF2,0x1194,0xFAF2,0x0436,0x0000},0x800F},
+       {LIVE  ,{0x1EB5,0xFCB6,0xC24A,0x1DF8,0x0E7C,0xC883,0x1C10,0x0699,0xDA41,0x1561,0x0295,0x0436,0x0000},0x800F},
+       {POP   ,{0x1E98,0xFCB6,0xC340,0x1D60,0x095B,0xC6AC,0x1BBC,0x0556,0x0689,0x0F33,0x0000,0xEDD1,0xF805},0x801F},
+       {ROCK  ,{0x1EB5,0xFCB6,0xC071,0x1F95,0x0424,0xC30A,0x1D27,0xF900,0x0C5D,0x0FC7,0x0E23,0x0436,0x0000},0x800F},
+       {OPPO  ,{0x0000,0x0000,0xCA4A,0x17F8,0x0FEC,0xCA4A,0x17F8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},0x800F},
+       {TREBLE,{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x188D,0x1699},0x8010},
+       {BASS  ,{0x1A43,0x0C00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},0x8001},
+       {EQTEST,{0x1F8C,0x1830,0xC118,0x1EEF,0xFD77,0xD8CB,0x1BBC,0x0556,0x0689,0x0F33,0x0000,0xF17F,0x0FEC},0x8003},
+};
+
+static const u16 rt5621_reg[RT5621_VENDOR_ID2 + 1] = {
+       [RT5621_RESET] = 0x59b4,
+       [RT5621_SPK_OUT_VOL] = 0x8080,
+       [RT5621_HP_OUT_VOL] = 0x8080,
+       [RT5621_MONO_AUX_OUT_VOL] = 0x8080,
+       [RT5621_AUXIN_VOL] = 0xe808,
+       [RT5621_LINE_IN_VOL] = 0xe808,
+       [RT5621_STEREO_DAC_VOL] = 0xe808,
+       [RT5621_MIC_VOL] = 0x0808,
+       [RT5621_MIC_ROUTING_CTRL] = 0xe0e0,
+       [RT5621_ADC_REC_GAIN] = 0xf58b,
+       [RT5621_ADC_REC_MIXER] = 0x7f7f,
+       [RT5621_SOFT_VOL_CTRL_TIME] = 0x000a,
+       [RT5621_OUTPUT_MIXER_CTRL] = 0xc000,
+       [RT5621_AUDIO_INTERFACE] = 0x8000,
+       [RT5621_STEREO_AD_DA_CLK_CTRL] = 0x166d,
+       [RT5621_ADD_CTRL_REG] = 0x5300,
+       [RT5621_GPIO_PIN_CONFIG] = 0x1c0e,
+       [RT5621_GPIO_PIN_POLARITY] = 0x1c0e,
+       [RT5621_GPIO_PIN_STATUS] = 0x0002,
+       [RT5621_OVER_TEMP_CURR_STATUS] = 0x003c,
+       [RT5621_PSEDUEO_SPATIAL_CTRL] = 0x0497,
+       [RT5621_AVC_CTRL] = 0x000b,
+       [RT5621_VENDOR_ID1] = 0x10ec,
+       [RT5621_VENDOR_ID2] = 0x2003,
+};
+
+#define rt5621_write_mask(c, reg, value, mask) snd_soc_update_bits(c, reg, mask, value)
+
+#define rt5621_write_index_reg(c, addr, data) \
+{ \
+       snd_soc_write(c, 0x6a, addr); \
+       snd_soc_write(c, 0x6c, data); \
+}
+
+static int rt5621_reset(struct snd_soc_codec *codec)
+{
+       return snd_soc_write(codec, RT5621_RESET, 0);
+}
+
+static int rt5621_volatile_register(
+       struct snd_soc_codec *codec, unsigned int reg)
+{
+       switch (reg) {
+       case RT5621_RESET:
+       case RT5621_HID_CTRL_DATA:
+       case RT5621_GPIO_PIN_STATUS:
+       case RT5621_OVER_TEMP_CURR_STATUS:
+               return 1;
+       default:
+               return 0;
+       }
+}
+
+static int rt5621_readable_register(
+       struct snd_soc_codec *codec, unsigned int reg)
+{
+       switch (reg) {
+       case RT5621_RESET:
+       case RT5621_SPK_OUT_VOL:
+       case RT5621_HP_OUT_VOL:
+       case RT5621_MONO_AUX_OUT_VOL:
+       case RT5621_AUXIN_VOL:
+       case RT5621_LINE_IN_VOL:
+       case RT5621_STEREO_DAC_VOL:
+       case RT5621_MIC_VOL:
+       case RT5621_MIC_ROUTING_CTRL:
+       case RT5621_ADC_REC_GAIN:
+       case RT5621_ADC_REC_MIXER:
+       case RT5621_SOFT_VOL_CTRL_TIME:
+       case RT5621_OUTPUT_MIXER_CTRL:
+       case RT5621_MIC_CTRL:
+       case RT5621_AUDIO_INTERFACE:
+       case RT5621_STEREO_AD_DA_CLK_CTRL:
+       case RT5621_COMPANDING_CTRL:
+       case RT5621_PWR_MANAG_ADD1:
+       case RT5621_PWR_MANAG_ADD2:
+       case RT5621_PWR_MANAG_ADD3:
+       case RT5621_ADD_CTRL_REG:
+       case RT5621_GLOBAL_CLK_CTRL_REG:
+       case RT5621_PLL_CTRL:
+       case RT5621_GPIO_OUTPUT_PIN_CTRL:
+       case RT5621_GPIO_PIN_CONFIG:
+       case RT5621_GPIO_PIN_POLARITY:
+       case RT5621_GPIO_PIN_STICKY:
+       case RT5621_GPIO_PIN_WAKEUP:
+       case RT5621_GPIO_PIN_STATUS:
+       case RT5621_GPIO_PIN_SHARING:
+       case RT5621_OVER_TEMP_CURR_STATUS:
+       case RT5621_JACK_DET_CTRL:
+       case RT5621_MISC_CTRL:
+       case RT5621_PSEDUEO_SPATIAL_CTRL:
+       case RT5621_EQ_CTRL:
+       case RT5621_EQ_MODE_ENABLE:
+       case RT5621_AVC_CTRL:
+       case RT5621_HID_CTRL_INDEX:
+       case RT5621_HID_CTRL_DATA:
+       case RT5621_VENDOR_ID1:
+       case RT5621_VENDOR_ID2:
+               return 1;
+       default:
+               return 0;
+       }
+}
+
+
+//static const char *rt5621_spkl_pga[] = {"Vmid","HPL mixer","SPK mixer","Mono Mixer"};
+static const char *rt5621_spkn_source_sel[] = {"RN", "RP", "LN"};
+static const char *rt5621_spk_pga[] = {"Vmid","HP mixer","SPK mixer","Mono Mixer"};
+static const char *rt5621_hpl_pga[]  = {"Vmid","HPL mixer"};
+static const char *rt5621_hpr_pga[]  = {"Vmid","HPR mixer"};
+static const char *rt5621_mono_pga[] = {"Vmid","HP mixer","SPK mixer","Mono Mixer"};
+static const char *rt5621_amp_type_sel[] = {"Class AB","Class D"};
+static const char *rt5621_mic_boost_sel[] = {"Bypass","20db","30db","40db"};
+
+static const struct soc_enum rt5621_enum[] = {
+SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 14, 3, rt5621_spkn_source_sel), /* spkn source from hp mixer */      
+SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 10, 4, rt5621_spk_pga), /* spk input sel 1 */        
+SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 9, 2, rt5621_hpl_pga), /* hp left input sel 2 */     
+SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 8, 2, rt5621_hpr_pga), /* hp right input sel 3 */    
+SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL, 6, 4, rt5621_mono_pga), /* mono input sel 4 */
+SOC_ENUM_SINGLE(RT5621_MIC_CTRL, 10,4, rt5621_mic_boost_sel), /*Mic1 boost sel 5 */
+SOC_ENUM_SINGLE(RT5621_MIC_CTRL, 8,4,rt5621_mic_boost_sel), /*Mic2 boost sel 6 */
+SOC_ENUM_SINGLE(RT5621_OUTPUT_MIXER_CTRL,13,2,rt5621_amp_type_sel), /*Speaker AMP sel 7 */
+};
+
+static int rt5621_amp_sel_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+       unsigned short val;
+       unsigned short mask, bitmask;
+
+       for (bitmask = 1; bitmask < e->max; bitmask <<= 1);
+
+       if (ucontrol->value.enumerated.item[0] > e->max - 1)
+               return -EINVAL;
+       val = ucontrol->value.enumerated.item[0] << e->shift_l;
+       mask = (bitmask - 1) << e->shift_l;
+       if (e->shift_l != e->shift_r) {
+               if (ucontrol->value.enumerated.item[1] > e->max - 1)
+                       return -EINVAL;
+               val |= ucontrol->value.enumerated.item[1] << e->shift_r;
+               mask |= (bitmask - 1) << e->shift_r;
+       }
+
+       snd_soc_update_bits(codec, e->reg, mask, val);
+       val &= (0x1 << 13);
+
+       if (val == 0)
+       {
+               snd_soc_update_bits(codec, 0x3c, 0x0000, 0x4000);       /*power off classd*/
+               snd_soc_update_bits(codec, 0x3c, 0x8000, 0x8000);       /*power on classab*/
+       } else {
+               snd_soc_update_bits(codec, 0x3c, 0x0000, 0x8000);       /*power off classab*/
+               snd_soc_update_bits(codec, 0x3c, 0x4000, 0x4000);       /*power on classd*/
+       }
+
+       return 0;
+}
+
+//*****************************************************************************
+//
+//function:Change audio codec power status
+//
+//*****************************************************************************
+static int rt5621_ChangeCodecPowerStatus(struct snd_soc_codec *codec,int power_state)
+{
+       unsigned short int PowerDownState=0;
+
+       switch(power_state) {
+       case POWER_STATE_D0: //FULL ON-----power on all power
+                       
+               snd_soc_write(codec,RT5621_PWR_MANAG_ADD1,~PowerDownState);
+               snd_soc_write(codec,RT5621_PWR_MANAG_ADD2,~PowerDownState);
+               snd_soc_write(codec,RT5621_PWR_MANAG_ADD3,~PowerDownState);
+               break;
+       case POWER_STATE_D1: //LOW ON-----
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD2 ,PWR_VREF |
+                       PWR_DAC_REF_CIR | PWR_L_DAC_CLK | PWR_R_DAC_CLK |
+                       PWR_L_HP_MIXER | PWR_R_HP_MIXER | PWR_L_ADC_CLK_GAIN |
+                       PWR_R_ADC_CLK_GAIN | PWR_L_ADC_REC_MIXER | PWR_R_ADC_REC_MIXER |
+                       PWR_CLASS_AB, PWR_VREF | PWR_DAC_REF_CIR | PWR_L_DAC_CLK |
+                       PWR_R_DAC_CLK | PWR_L_HP_MIXER | PWR_R_HP_MIXER |
+                       PWR_L_ADC_CLK_GAIN | PWR_R_ADC_CLK_GAIN |
+                       PWR_L_ADC_REC_MIXER | PWR_R_ADC_REC_MIXER | PWR_CLASS_AB);
+
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD3 ,PWR_MAIN_BIAS |
+                       PWR_HP_R_OUT_VOL | PWR_HP_L_OUT_VOL | PWR_SPK_OUT |
+                       PWR_MIC1_FUN_CTRL | PWR_MIC1_BOOST_MIXER, PWR_MAIN_BIAS |
+                       PWR_HP_R_OUT_VOL | PWR_HP_L_OUT_VOL | PWR_SPK_OUT |
+                       PWR_MIC1_FUN_CTRL | PWR_MIC1_BOOST_MIXER);
+
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1 ,PWR_MAIN_I2S_EN |
+                       PWR_HP_OUT_ENH_AMP | PWR_HP_OUT_AMP | PWR_MIC1_BIAS_EN,
+                       PWR_MAIN_I2S_EN | PWR_HP_OUT_ENH_AMP | PWR_HP_OUT_AMP |
+                       PWR_MIC1_BIAS_EN);
+               break;
+
+       case POWER_STATE_D1_PLAYBACK: //Low on of Playback
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD2, PWR_VREF | PWR_DAC_REF_CIR |
+                       PWR_L_DAC_CLK | PWR_R_DAC_CLK | PWR_L_HP_MIXER | PWR_R_HP_MIXER |
+                       PWR_CLASS_AB | PWR_CLASS_D, PWR_VREF | PWR_DAC_REF_CIR |
+                       PWR_L_DAC_CLK | PWR_R_DAC_CLK | PWR_L_HP_MIXER | PWR_R_HP_MIXER |
+                       PWR_CLASS_AB | PWR_CLASS_D);
+
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD3, PWR_MAIN_BIAS |
+                       PWR_HP_R_OUT_VOL | PWR_HP_L_OUT_VOL | PWR_SPK_OUT, 
+                       PWR_MAIN_BIAS | PWR_HP_R_OUT_VOL | PWR_HP_L_OUT_VOL | PWR_SPK_OUT);             
+
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1, PWR_MAIN_I2S_EN |
+                       PWR_HP_OUT_ENH_AMP | PWR_HP_OUT_AMP, PWR_MAIN_I2S_EN |
+                       PWR_HP_OUT_ENH_AMP | PWR_HP_OUT_AMP);
+               break;
+
+       case POWER_STATE_D1_RECORD: //Low on of Record
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1, PWR_MAIN_I2S_EN |
+                       PWR_MIC1_BIAS_EN, PWR_MAIN_I2S_EN | PWR_MIC1_BIAS_EN);                                                   
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD2, PWR_VREF |
+                       PWR_L_ADC_CLK_GAIN | PWR_R_ADC_CLK_GAIN | PWR_L_ADC_REC_MIXER |
+                       PWR_R_ADC_REC_MIXER, PWR_VREF | PWR_L_ADC_CLK_GAIN |
+                       PWR_R_ADC_CLK_GAIN | PWR_L_ADC_REC_MIXER | PWR_R_ADC_REC_MIXER);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD3, PWR_MAIN_BIAS |
+                       PWR_MIC2_BOOST_MIXER | PWR_MIC1_BOOST_MIXER, PWR_MAIN_BIAS |
+                       PWR_MIC2_BOOST_MIXER | PWR_MIC1_BOOST_MIXER);
+               break;
+
+       case POWER_STATE_D2: //STANDBY----
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1, 0, PWR_MAIN_I2S_EN |
+                       PWR_HP_OUT_ENH_AMP | PWR_HP_OUT_AMP | PWR_MIC1_BIAS_EN);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD3, 0, PWR_HP_R_OUT_VOL |
+                       PWR_HP_L_OUT_VOL | PWR_SPK_OUT | PWR_MIC1_FUN_CTRL |
+                       PWR_MIC1_BOOST_MIXER);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD2, 0, PWR_DAC_REF_CIR |
+                       PWR_L_DAC_CLK | PWR_R_DAC_CLK | PWR_L_HP_MIXER | PWR_R_HP_MIXER|
+                       PWR_L_ADC_CLK_GAIN | PWR_R_ADC_CLK_GAIN | PWR_L_ADC_REC_MIXER |
+                       PWR_R_ADC_REC_MIXER | PWR_CLASS_AB | PWR_CLASS_D);
+               break;
+
+       case POWER_STATE_D2_PLAYBACK: //STANDBY of playback
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD3, 0, /*PWR_HP_R_OUT_VOL |
+                       PWR_HP_L_OUT_VOL |*/ PWR_SPK_OUT);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1, 0, PWR_HP_OUT_ENH_AMP |
+                       PWR_HP_OUT_AMP);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD2, 0, PWR_DAC_REF_CIR |
+                       PWR_L_DAC_CLK | PWR_R_DAC_CLK | PWR_L_HP_MIXER | PWR_R_HP_MIXER |
+                       PWR_CLASS_AB | PWR_CLASS_D);
+               break;
+
+       case POWER_STATE_D2_RECORD: //STANDBY of record
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1, 0, PWR_MIC1_BIAS_EN);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD2, 0, PWR_L_ADC_CLK_GAIN |
+                       PWR_R_ADC_CLK_GAIN | PWR_L_ADC_REC_MIXER | PWR_R_ADC_REC_MIXER);
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD3, 0, PWR_MIC2_BOOST_MIXER |
+                       PWR_MIC1_BOOST_MIXER);          
+               break;
+
+       case POWER_STATE_D3: //SLEEP
+       case POWER_STATE_D4: //OFF----power off all power
+               rt5621_write_mask(codec, RT5621_PWR_MANAG_ADD1, 0, PWR_HP_OUT_ENH_AMP |
+                       PWR_HP_OUT_AMP);                
+               snd_soc_write(codec, RT5621_PWR_MANAG_ADD3, 0);
+               snd_soc_write(codec, RT5621_PWR_MANAG_ADD1, 0);
+               snd_soc_write(codec, RT5621_PWR_MANAG_ADD2, 0);
+               break;
+
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+
+//*****************************************************************************
+//
+//function AudioOutEnable:Mute/Unmute audio out channel
+//WavOutPath:output channel
+//Mute :Mute/Unmute output channel
+//
+//*****************************************************************************
+static int rt5621_AudioOutEnable(struct snd_soc_codec *codec,
+       unsigned short int WavOutPath, int Mute)
+{
+       int RetVal=0;   
+
+       if(Mute) {
+               switch(WavOutPath) {
+               case RT_WAVOUT_ALL_ON:
+                       RetVal = rt5621_write_mask(codec, RT5621_SPK_OUT_VOL, RT_L_MUTE | RT_R_MUTE,
+                               RT_L_MUTE | RT_R_MUTE); //Mute Speaker right/left channel
+                       RetVal = rt5621_write_mask(codec, RT5621_HP_OUT_VOL, RT_L_MUTE | RT_R_MUTE,
+                               RT_L_MUTE | RT_R_MUTE); //Mute headphone right/left channel
+                       RetVal = rt5621_write_mask(codec, RT5621_MONO_AUX_OUT_VOL, RT_L_MUTE |
+                               RT_R_MUTE, RT_L_MUTE | RT_R_MUTE); //Mute Aux/Mono right/left channel
+                       RetVal = rt5621_write_mask(codec, RT5621_STEREO_DAC_VOL, RT_M_HP_MIXER |
+                               RT_M_SPK_MIXER | RT_M_MONO_MIXER, RT_M_HP_MIXER |
+                               RT_M_SPK_MIXER | RT_M_MONO_MIXER); //Mute DAC to HP,Speaker,Mono Mixer
+                       break;
+
+               case RT_WAVOUT_HP:
+                       RetVal = rt5621_write_mask(codec, RT5621_HP_OUT_VOL, RT_L_MUTE | RT_R_MUTE,
+                               RT_L_MUTE | RT_R_MUTE); //Mute headphone right/left channel
+                       break;
+
+               case RT_WAVOUT_SPK:
+                       RetVal = rt5621_write_mask(codec, RT5621_SPK_OUT_VOL, RT_L_MUTE | RT_R_MUTE,
+                               RT_L_MUTE | RT_R_MUTE); //Mute Speaker right/left channel                       
+                       break;
+
+               case RT_WAVOUT_AUXOUT:
+                       RetVal = rt5621_write_mask(codec, RT5621_MONO_AUX_OUT_VOL, RT_L_MUTE |
+                               RT_R_MUTE, RT_L_MUTE | RT_R_MUTE); //Mute AuxOut right/left channel
+                       break;
+
+               case RT_WAVOUT_MONO:
+
+                       RetVal = rt5621_write_mask(codec, RT5621_MONO_AUX_OUT_VOL, RT_L_MUTE,
+                               RT_L_MUTE); //Mute MonoOut channel
+                       break;
+
+               case RT_WAVOUT_DAC:
+                       RetVal = rt5621_write_mask(codec, RT5621_STEREO_DAC_VOL, RT_M_HP_MIXER |
+                               RT_M_SPK_MIXER | RT_M_MONO_MIXER, RT_M_HP_MIXER | RT_M_SPK_MIXER |
+                               RT_M_MONO_MIXER); //Mute DAC to HP,Speaker,Mono Mixer                           
+                       break;
+
+               default:
+                       return 0;
+               }
+       } else {
+               switch(WavOutPath) {
+               case RT_WAVOUT_ALL_ON:
+                       RetVal = rt5621_write_mask(codec, RT5621_SPK_OUT_VOL, 0, RT_L_MUTE |
+                               RT_R_MUTE); //Mute Speaker right/left channel
+                       RetVal = rt5621_write_mask(codec, RT5621_HP_OUT_VOL, 0, RT_L_MUTE |
+                               RT_R_MUTE); //Mute headphone right/left channel
+                       RetVal = rt5621_write_mask(codec, RT5621_MONO_AUX_OUT_VOL, 0, RT_L_MUTE |
+                               RT_R_MUTE); //Mute Aux/Mono right/left channel
+                       RetVal = rt5621_write_mask(codec, RT5621_STEREO_DAC_VOL, 0, RT_M_HP_MIXER |
+                               RT_M_SPK_MIXER | RT_M_MONO_MIXER); //Mute DAC to HP,Speaker,Mono Mixer
+                       break;
+               case RT_WAVOUT_HP:
+                       RetVal = rt5621_write_mask(codec, RT5621_HP_OUT_VOL, 0, RT_L_MUTE |
+                               RT_R_MUTE); //UnMute headphone right/left channel
+                       break;
+
+               case RT_WAVOUT_SPK:
+                       RetVal = rt5621_write_mask(codec, RT5621_SPK_OUT_VOL, 0, RT_L_MUTE |
+                               RT_R_MUTE); //unMute Speaker right/left channel
+                       break;
+               case RT_WAVOUT_AUXOUT:
+                       RetVal = rt5621_write_mask(codec, RT5621_MONO_AUX_OUT_VOL, 0, RT_L_MUTE |
+                               RT_R_MUTE); //unMute AuxOut right/left channel
+                       break;
+
+               case RT_WAVOUT_MONO:
+                       RetVal = rt5621_write_mask(codec, RT5621_MONO_AUX_OUT_VOL, 0, 
+                               RT_L_MUTE); //unMute MonoOut channel
+                       break;
+
+               case RT_WAVOUT_DAC:
+                       RetVal = rt5621_write_mask(codec, RT5621_STEREO_DAC_VOL, 0, RT_M_HP_MIXER |
+                               RT_M_SPK_MIXER | RT_M_MONO_MIXER); //unMute DAC to HP,Speaker,Mono Mixer
+                       break;
+               default:
+                       return 0;
+               }
+
+       }
+
+       return RetVal;
+}
+
+
+//*****************************************************************************
+//
+//function:Enable/Disable ADC input source control
+//
+//*****************************************************************************
+static int Enable_ADC_Input_Source(struct snd_soc_codec *codec,unsigned short int ADC_Input_Sour,int Enable)
+{
+       int bRetVal=0;
+       
+       if(Enable) {
+               //Enable ADC source 
+               bRetVal=rt5621_write_mask(codec,RT5621_ADC_REC_MIXER,0,ADC_Input_Sour);
+       } else {
+               //Disable ADC source            
+               bRetVal=rt5621_write_mask(codec,RT5621_ADC_REC_MIXER,ADC_Input_Sour,ADC_Input_Sour);
+       }
+
+       return bRetVal;
+}
+
+static void rt5621_update_eqmode(struct snd_soc_codec *codec, int mode)
+{
+       u16 HwEqIndex=0;
+
+       if (mode == NORMAL) {
+               /*clear EQ parameter*/
+               for (HwEqIndex=0; HwEqIndex<=0x0C; HwEqIndex++) {
+
+                       rt5621_write_index_reg(codec, HwEqIndex, HwEq_Preset[mode].EqValue[HwEqIndex])
+               }
+               
+               snd_soc_write(codec, 0x62, 0x0);                /*disable EQ block*/
+       } else {
+               snd_soc_write(codec, 0x62, HwEq_Preset[mode].HwEQCtrl);
+
+               /*Fill EQ parameter*/
+               for (HwEqIndex=0; HwEqIndex<=0x0C; HwEqIndex++) {
+
+                       rt5621_write_index_reg(codec, HwEqIndex, HwEq_Preset[mode].EqValue[HwEqIndex]) 
+               }               
+               //update EQ parameter
+               snd_soc_write(codec, 0x66, 0x1f);
+               schedule_timeout_uninterruptible(msecs_to_jiffies(1));
+               snd_soc_write(codec, 0x66, 0x0);
+       }
+}
+
+static const struct snd_kcontrol_new rt5621_snd_controls[] = {
+SOC_DOUBLE("Speaker Playback Volume",  RT5621_SPK_OUT_VOL, 8, 0, 31, 1),       
+SOC_DOUBLE("Speaker Playback Switch",  RT5621_SPK_OUT_VOL, 15, 7, 1, 1),
+SOC_DOUBLE("Headphone Playback Volume", RT5621_HP_OUT_VOL, 8, 0, 31, 1),
+SOC_DOUBLE("Headphone Playback Switch", RT5621_HP_OUT_VOL,15, 7, 1, 1),
+SOC_DOUBLE("AUX Playback Volume",              RT5621_MONO_AUX_OUT_VOL, 8, 0, 31, 1),
+SOC_DOUBLE("AUX Playback Switch",              RT5621_MONO_AUX_OUT_VOL, 15, 7, 1, 1),
+SOC_DOUBLE("PCM Playback Volume",              RT5621_STEREO_DAC_VOL, 8, 0, 31, 1),
+SOC_DOUBLE("Line In Volume",                   RT5621_LINE_IN_VOL, 8, 0, 31, 1),
+SOC_SINGLE("Mic 1 Volume",                             RT5621_MIC_VOL, 8, 31, 1),
+SOC_SINGLE("Mic 2 Volume",                             RT5621_MIC_VOL, 0, 31, 1),
+SOC_ENUM("Mic 1 Boost",                                rt5621_enum[5]),
+SOC_ENUM("Mic 2 Boost",                                rt5621_enum[6]),
+SOC_ENUM_EXT("Speaker Amp Type",                       rt5621_enum[7], snd_soc_get_enum_double, rt5621_amp_sel_put),
+SOC_DOUBLE("AUX In Volume",                    RT5621_AUXIN_VOL, 8, 0, 31, 1),
+SOC_DOUBLE("Capture Volume",                   RT5621_ADC_REC_GAIN, 7, 0, 31, 0),
+};
+
+void hp_depop_mode2(struct snd_soc_codec *codec)
+{
+       snd_soc_update_bits(codec, 0x3e, 0x8000, 0x8000);
+       snd_soc_update_bits(codec, 0x04, 0x8080, 0x8080);
+       snd_soc_update_bits(codec, 0x3a, 0x0100, 0x0100);
+       snd_soc_update_bits(codec, 0x3c, 0x2000, 0x2000);
+       snd_soc_update_bits(codec, 0x3e, 0x0600, 0x0600);
+       snd_soc_update_bits(codec, 0x5e, 0x0200, 0x0200);
+       schedule_timeout_uninterruptible(msecs_to_jiffies(300));
+}
+
+void aux_depop_mode2(struct snd_soc_codec *codec)
+{
+       snd_soc_update_bits(codec, 0x3e, 0x8000, 0x8000);
+       snd_soc_update_bits(codec, 0x06, 0x8080, 0x8080);
+       snd_soc_update_bits(codec, 0x3a, 0x0100, 0x0100);
+       snd_soc_update_bits(codec, 0x3c, 0x2000, 0x2000);
+       snd_soc_update_bits(codec, 0x3e, 0x6000, 0x6000);
+       snd_soc_update_bits(codec, 0x5e, 0x0020, 0x0200);
+       schedule_timeout_uninterruptible(msecs_to_jiffies(300));
+       snd_soc_update_bits(codec, 0x3a, 0x0002, 0x0002);
+       snd_soc_update_bits(codec, 0x3a, 0x0001, 0x0001);       
+}
+
+static int rt5621_pcm_hw_prepare(struct snd_pcm_substream *substream,
+               struct snd_soc_dai *codec_dai)
+{
+
+       struct snd_soc_codec *codec = codec_dai->codec;
+       int stream = substream->stream;
+
+       switch (stream)
+       {
+               case SNDRV_PCM_STREAM_PLAYBACK:
+
+                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D1_PLAYBACK);   //power on dac to hp and speaker out
+                                               
+                       rt5621_AudioOutEnable(codec,RT_WAVOUT_SPK,0);   //unmute speaker out
+                       
+                       rt5621_AudioOutEnable(codec,RT_WAVOUT_HP,0);    //unmute hp
+                       
+                       rt5621_AudioOutEnable(codec,RT_WAVOUT_AUXOUT,0);        //unmute auxout out
+
+                       break;
+               case SNDRV_PCM_STREAM_CAPTURE:
+
+                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D1_RECORD);     //power on input to adc
+
+                       Enable_ADC_Input_Source(codec,RT_WAVIN_L_MIC1|RT_WAVIN_R_MIC1,1);       //enable record source from mic1
+
+                       break;                  
+       }
+       
+       return 0;
+}
+
+/* PLL divisors */
+struct _pll_div {
+       u32 pll_in;
+       u32 pll_out;
+       u16 regvalue;
+};
+
+static const struct _pll_div codec_pll_div[] = {
+       
+       {  2048000,  8192000,   0x0ea0},                
+       {  3686400,  8192000,   0x4e27},        
+       { 12000000,  8192000,   0x456b},   
+       { 13000000,  8192000,   0x495f},
+       { 13100000,      8192000,       0x0320},        
+       {  2048000,  11289600,  0xf637},
+       {  3686400,  11289600,  0x2f22},        
+       { 12000000,  11289600,  0x3e2f},   
+       { 13000000,  11289600,  0x4d5b},
+       { 13100000,      11289600,      0x363b},        
+       {  2048000,  16384000,  0x1ea0},
+       {  3686400,  16384000,  0x9e27},        
+       { 12000000,  16384000,  0x452b},   
+       { 13000000,  16384000,  0x542f},
+       { 13100000,      16384000,      0x03a0},        
+       {  2048000,  16934400,  0xe625},
+       {  3686400,  16934400,  0x9126},        
+       { 12000000,  16934400,  0x4d2c},   
+       { 13000000,  16934400,  0x742f},
+       { 13100000,      16934400,      0x3c27},                        
+       {  2048000,  22579200,  0x2aa0},
+       {  3686400,  22579200,  0x2f20},        
+       { 12000000,  22579200,  0x7e2f},   
+       { 13000000,  22579200,  0x742f},
+       { 13100000,      22579200,      0x3c27},                
+       {  2048000,  24576000,  0x2ea0},
+       {  3686400,  24576000,  0xee27},        
+       { 12000000,  24576000,  0x2915},   
+       { 13000000,  24576000,  0x772e},
+       { 13100000,      24576000,      0x0d20},        
+};
+
+static const struct _pll_div codec_bclk_pll_div[] = {
+
+       {  1536000,      24576000,      0x3ea0},        
+       {  3072000,      24576000,      0x1ea0},
+       {  512000,       24576000,  0x8e90},
+       {  256000,   24576000,  0xbe80},
+       {  2822400,      11289600,      0x1ee0},
+       {  3072000,      12288000,      0x1ee0},                
+};
+
+
+static int rt5621_set_dai_pll(struct snd_soc_dai *dai,
+               int pll_id,int source, unsigned int freq_in, unsigned int freq_out)
+{
+       int i;
+       int ret = -EINVAL;
+       struct snd_soc_codec *codec = dai->codec;
+
+       if (pll_id < RT5621_PLL_FR_MCLK || pll_id > RT5621_PLL_FR_BCLK)
+               return -EINVAL;
+
+       //rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2, 0x0000,0x1000);        //disable PLL power     
+       
+       if (!freq_in || !freq_out) {
+
+               return 0;
+       }               
+
+       if (RT5621_PLL_FR_MCLK == pll_id) {
+       for (i = 0; i < ARRAY_SIZE(codec_pll_div); i++) {
+                       
+               if (codec_pll_div[i].pll_in == freq_in && codec_pll_div[i].pll_out == freq_out)
+                       {
+                               snd_soc_update_bits(codec, RT5621_GLOBAL_CLK_CTRL_REG, 0x0000, 0x4000);                         
+                               snd_soc_write(codec,RT5621_PLL_CTRL,codec_pll_div[i].regvalue);//set PLL parameter      
+                               snd_soc_update_bits(codec,RT5621_PWR_MANAG_ADD2, 0x1000,0x1000);        //enable PLL power      
+                               ret = 0;
+                       }
+       }
+       }
+       else if (RT5621_PLL_FR_BCLK == pll_id)
+       {
+               for (i = 0; i < ARRAY_SIZE(codec_bclk_pll_div); i++)
+               {
+                       if ((freq_in == codec_bclk_pll_div[i].pll_in) && (freq_out == codec_bclk_pll_div[i].pll_out))
+                       {
+                               snd_soc_update_bits(codec, RT5621_GLOBAL_CLK_CTRL_REG, 0x4000, 0x4000);
+                               snd_soc_write(codec,RT5621_PLL_CTRL,codec_bclk_pll_div[i].regvalue);//set PLL parameter 
+                               snd_soc_update_bits(codec,RT5621_PWR_MANAG_ADD2, 0x1000,0x1000);        //enable PLL power      
+                               ret = 0;
+                       }
+               }
+       }
+
+       snd_soc_update_bits(codec,RT5621_GLOBAL_CLK_CTRL_REG,0x8000,0x8000);//Codec sys-clock from PLL  
+       return ret;
+}
+
+
+struct _coeff_div {
+       u32 mclk;
+       u32 rate;
+       u16 fs;
+       u16 regvalue;
+};
+
+/* codec hifi mclk (after PLL) clock divider coefficients */
+static const struct _coeff_div coeff_div[] = {
+       /* 8k */
+       { 8192000,  8000, 256*4, 0x2a2d},
+       {12288000,  8000, 384*4, 0x2c2f},
+
+       /* 11.025k */
+       {11289600, 11025, 256*4, 0x2a2d},
+       {16934400, 11025, 384*4, 0x2c2f},
+
+       /* 16k */
+       {12288000, 16000, 384*2, 0x1c2f},
+       {16384000, 16000, 256*4, 0x2a2d},
+       {24576000, 16000, 384*4, 0x2c2f},
+
+       /* 22.05k */    
+       {11289600, 22050, 256*2, 0x1a2d},
+       {16934400, 22050, 384*2, 0x1c2f},
+
+       /* 32k */
+       {12288000, 32000, 384  , 0x0c2f},
+       {16384000, 32000, 256*2, 0x1a2d},
+       {24576000, 32000, 384*2, 0x1c2f},
+
+       /* 44.1k */
+       {11289600, 44100, 256*1, 0x0a2d},
+       {22579200, 44100, 256*2, 0x1a2d},
+       {45158400, 44100, 256*4, 0x2a2d},       
+
+       /* 48k */
+       {12288000, 48000, 256*1, 0x0a2d},
+       {24576000, 48000, 256*2, 0x1a2d},
+       {49152000, 48000, 256*4, 0x2a2d},
+
+       //MCLK is 24.576Mhz(for 8k,16k,32k)
+       {24576000,  8000, 384*8, 0x3c6b},
+       {24576000, 16000, 384*4, 0x2c6b},
+       {24576000, 32000, 384*2, 0x1c6b},
+
+       //MCLK is 22.5792mHz(for 11k,22k)
+       {22579200, 11025, 256*8, 0x3a2d},
+       {22579200, 22050, 256*4, 0x2a2d},
+};
+
+
+
+static int get_coeff(int mclk, int rate)
+{
+       int i;
+       
+       DBG("get_coeff mclk=%d,rate=%d\n",mclk,rate);
+
+       for (i = 0; i < ARRAY_SIZE(coeff_div); i++) {
+               if (coeff_div[i].rate == rate && coeff_div[i].mclk == mclk)
+                       return i;
+       }
+       return -EINVAL;
+}
+
+
+/*
+ * Clock after PLL and dividers
+ */
+ /*in this driver, you have to set sysclk to be 24576000,
+ * but you don't need to give a clk to be 24576000, our 
+ * internal pll will generate this clock! so it won't make
+ * you any difficult.
+ */
+static int rt5621_set_dai_sysclk(struct snd_soc_dai *dai,
+               int clk_id, unsigned int freq, int dir)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       struct rt5621_priv *rt5621 = snd_soc_codec_get_drvdata(codec);
+
+       if ((freq >= (256 * 8000)) && (freq <= (512 * 48000))) {
+               rt5621->sysclk = freq;
+               return 0;
+       }
+
+       printk("unsupported sysclk freq %u for audio i2s\n", freq);
+
+       return -EINVAL;
+}
+
+
+static int rt5621_set_dai_fmt(struct snd_soc_dai *dai,
+               unsigned int fmt)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       u16 iface = 0;
+
+       /* set master/slave audio interface */
+       switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+       case SND_SOC_DAIFMT_CBM_CFM:
+               iface = 0x0000;
+               break;
+       case SND_SOC_DAIFMT_CBS_CFS:
+               iface = 0x8000;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* interface format */
+       switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+       case SND_SOC_DAIFMT_I2S:
+               iface |= 0x0000;
+               break;
+       case SND_SOC_DAIFMT_RIGHT_J:
+               iface |= 0x0001;
+               break;
+       case SND_SOC_DAIFMT_LEFT_J:
+               iface |= 0x0002;
+               break;
+       case SND_SOC_DAIFMT_DSP_A:
+               iface |= 0x0003;
+               break;
+       case SND_SOC_DAIFMT_DSP_B:
+               iface |= 0x4003;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       /* clock inversion */
+       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       case SND_SOC_DAIFMT_NB_NF:
+               iface |= 0x0000;
+               break;
+       case SND_SOC_DAIFMT_IB_NF:
+               iface |= 0x0100;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       snd_soc_write(codec,RT5621_AUDIO_INTERFACE,iface);
+       return 0;
+}
+
+
+static int rt5621_pcm_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       struct rt5621_priv *rt5621 = snd_soc_codec_get_drvdata(codec);
+       u16 iface = snd_soc_read(codec,RT5621_AUDIO_INTERFACE)&0xfff3;
+       int coeff = get_coeff(rt5621->sysclk, params_rate(params));
+
+       DBG("rt5621_pcm_hw_params\n");
+       if (coeff < 0)
+               coeff = get_coeff(24576000, params_rate(params));         /*if not set sysclk, default to be 24.576MHz*/
+
+       /* bit size */
+       switch (params_format(params)) {
+       case SNDRV_PCM_FORMAT_S16_LE:
+               iface |= 0x0000;
+               break;
+       case SNDRV_PCM_FORMAT_S20_3LE:
+               iface |= 0x0004;
+               break;
+       case SNDRV_PCM_FORMAT_S24_LE:
+               iface |= 0x0008;
+               break;
+       case SNDRV_PCM_FORMAT_S32_LE:
+               iface |= 0x000c;
+               break;
+       }
+
+       /* set iface & srate */
+       snd_soc_write(codec, RT5621_AUDIO_INTERFACE, iface);
+
+       if (coeff >= 0)
+               snd_soc_write(codec, RT5621_STEREO_AD_DA_CLK_CTRL, coeff_div[coeff].regvalue);
+       else
+       {
+               printk(KERN_ERR "cant find matched sysclk and rate config\n");
+               return -EINVAL;
+               
+       }
+       return 0;
+}
+
+static int rt5621_set_bias_level(struct snd_soc_codec *codec,
+                       enum snd_soc_bias_level level)
+{
+       switch (level) {
+       case SND_SOC_BIAS_ON:
+               snd_soc_update_bits(codec, RT5621_SPK_OUT_VOL, RT_L_MUTE | RT_R_MUTE, 0);
+               snd_soc_update_bits(codec, RT5621_HP_OUT_VOL, RT_L_MUTE | RT_R_MUTE, 0);
+               break;
+
+       case SND_SOC_BIAS_PREPARE:
+               break;
+
+       case SND_SOC_BIAS_STANDBY:
+               snd_soc_update_bits(codec, RT5621_SPK_OUT_VOL, RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE);
+               snd_soc_update_bits(codec, RT5621_HP_OUT_VOL, RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE);
+               if (SND_SOC_BIAS_OFF == codec->dapm.bias_level) {
+                       snd_soc_write(codec, RT5621_PWR_MANAG_ADD3, 0x8000);//enable Main bias
+                       snd_soc_write(codec, RT5621_PWR_MANAG_ADD2, 0x2000);//enable Vref
+                       codec->cache_only = false;
+                       snd_soc_cache_sync(codec);
+               }
+               break;
+
+       case SND_SOC_BIAS_OFF:
+               snd_soc_update_bits(codec, RT5621_SPK_OUT_VOL, RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE);
+               snd_soc_update_bits(codec, RT5621_HP_OUT_VOL, RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE);
+               snd_soc_write(codec, RT5621_PWR_MANAG_ADD3, 0x0000);
+               snd_soc_write(codec, RT5621_PWR_MANAG_ADD2, 0x0000);
+               snd_soc_write(codec, RT5621_PWR_MANAG_ADD1, 0x0000);
+               break;
+
+       default:
+               break;
+       }
+       codec->dapm.bias_level = level;
+
+       return 0;
+}
+
+
+
+struct rt5621_init_reg{
+
+       u8 reg_index;
+       u16 reg_value;
+};
+
+static struct rt5621_init_reg init_data[] = {
+       {RT5621_AUDIO_INTERFACE,        0x8000},    //set I2S codec to slave mode
+       {RT5621_STEREO_DAC_VOL,         0x0505},    //default stereo DAC volume to 0db
+       {RT5621_OUTPUT_MIXER_CTRL,      0x2b40},    //default output mixer control      
+       {RT5621_ADC_REC_MIXER,          0x3f3f},    //set record source is Mic1 by default
+       {RT5621_MIC_CTRL,               0x0a00},    //set Mic1,Mic2 boost 20db  
+       {RT5621_SPK_OUT_VOL,            0x8080},    //default speaker volume to 0db 
+       {RT5621_HP_OUT_VOL,             0x8080},    //default HP volume to -12db        
+       {RT5621_ADD_CTRL_REG,           0x4b00},    //Class AB/D speaker ratio is 1.25VDD
+       {RT5621_STEREO_AD_DA_CLK_CTRL,  0x066d},    //set Dac filter to 256fs
+       {RT5621_ADC_REC_GAIN,               0xfa95},    //set ADC boost to 15db 
+       {RT5621_HID_CTRL_INDEX,         0x46},      //Class D setting
+       {RT5621_MIC_VOL,              0x1f08},
+       {RT5621_HID_CTRL_DATA,          0xFFFF},    //power on Class D Internal register
+       {RT5621_JACK_DET_CTRL,          0x4810},    //power on Class D Internal register
+};
+#define RT5621_INIT_REG_NUM ARRAY_SIZE(init_data)
+
+static int rt5621_reg_init(struct snd_soc_codec *codec)
+{
+       int i;
+
+       for (i = 0; i < RT5621_INIT_REG_NUM; i++)
+               snd_soc_write(codec, init_data[i].reg_index, init_data[i].reg_value);
+
+       return 0;
+}
+
+void codec_set_spk(bool on)
+{
+       struct snd_soc_codec *codec = rt5621_codec; 
+
+       DBG("%s: %d\n", __func__, on);
+
+       if(!codec)
+               return;
+
+       if(on){
+               DBG("snd_soc_dapm_enable_pin\n");
+               snd_soc_dapm_enable_pin(&codec->dapm, "Headphone Jack");
+               snd_soc_dapm_enable_pin(&codec->dapm, "Ext Spk");
+       }
+       else{
+
+               DBG("snd_soc_dapm_disable_pin\n");
+               snd_soc_dapm_disable_pin(&codec->dapm, "Headphone Jack");
+               snd_soc_dapm_disable_pin(&codec->dapm, "Ext Spk");
+       }
+
+       snd_soc_dapm_sync(&codec->dapm);
+
+       return;
+}
+
+static void rt5621_work(struct work_struct *work)
+{
+       struct snd_soc_codec *codec = rt5621_codec;
+       
+       rt5621_set_bias_level(codec, codec->dapm.bias_level);
+}
+
+static int rt5621_probe(struct snd_soc_codec *codec)
+{
+       int ret;
+
+       ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C);
+       if (ret != 0) {
+               dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+               return ret;
+       }
+       codec->cache_bypass = 1;
+
+       rt5621_reset(codec);
+       snd_soc_write(codec, RT5621_PWR_MANAG_ADD3, 0x8000);//enable Main bias
+       snd_soc_write(codec, RT5621_PWR_MANAG_ADD2, 0x2000);//enable Vref
+       hp_depop_mode2(codec);
+       rt5621_reg_init(codec);
+
+#if ENABLE_EQ_HREQ             
+
+       rt5621_write_index_reg(codec, 0x11,0x1);
+       rt5621_write_index_reg(codec, 0x12,0x1);
+       rt5621_update_eqmode(codec, HFREQ);
+       
+#endif
+       rt5621_workq = create_freezable_workqueue("rt5621");
+       if (rt5621_workq == NULL) {
+               printk("wm8900_probe::create_freezeable_workqueue ERROR !");
+               kfree(codec);
+               return -ENOMEM;
+       }
+
+       rt5621_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
+       codec->dapm.bias_level = SND_SOC_BIAS_STANDBY;
+
+       queue_delayed_work(rt5621_workq, &delayed_work,
+               msecs_to_jiffies(caps_charge));
+
+       codec->dapm.bias_level = SND_SOC_BIAS_STANDBY;
+
+       rt5621_codec = codec;
+
+       return 0;
+}
+
+static int rt5621_remove(struct snd_soc_codec *codec)
+{
+       rt5621_set_bias_level(codec, SND_SOC_BIAS_OFF);
+
+       cancel_delayed_work_sync(&delayed_work);
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int rt5621_suspend(struct snd_soc_codec *codec, pm_message_t state)
+{
+       rt5621_set_bias_level(codec, SND_SOC_BIAS_OFF);
+       return 0;
+}
+
+static int rt5621_resume(struct snd_soc_codec *codec)
+{
+
+       rt5621_reset(codec);
+       snd_soc_write(codec, RT5621_PWR_MANAG_ADD3, 0x8000);//enable Main bias
+       snd_soc_write(codec, RT5621_PWR_MANAG_ADD2, 0x2000);//enable Vref
+
+       hp_depop_mode2(codec);
+
+       rt5621_reg_init(codec);
+
+#if ENABLE_EQ_HREQ             
+
+       rt5621_write_index_reg(codec, 0x11,0x1);
+       rt5621_write_index_reg(codec, 0x12,0x1);
+       rt5621_update_eqmode(codec, HFREQ);
+#endif 
+
+       rt5621_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
+       if (codec->dapm.suspend_bias_level == SND_SOC_BIAS_ON) {
+               rt5621_set_bias_level(codec, SND_SOC_BIAS_PREPARE);
+               codec->dapm.bias_level = SND_SOC_BIAS_ON;
+               queue_delayed_work(rt5621_workq, &delayed_work,
+                       msecs_to_jiffies(caps_charge));
+       }
+       return 0;
+}
+#else
+#define rt5621_suspend NULL
+#define rt5621_resume NULL
+#endif
+
+static void rt5621_shutdown(struct snd_pcm_substream *substream,
+               struct snd_soc_dai *codec_dai)
+{
+       struct snd_soc_codec *codec = codec_dai->codec;
+       int stream = substream->stream;
+       
+       switch (stream)
+       {
+               case SNDRV_PCM_STREAM_PLAYBACK:
+
+                       rt5621_AudioOutEnable(codec,RT_WAVOUT_SPK,1);   //mute speaker out
+                       
+                       rt5621_AudioOutEnable(codec,RT_WAVOUT_HP,1);    //mute hp out
+                       
+                       rt5621_AudioOutEnable(codec,RT_WAVOUT_AUXOUT,1);        //mute auxout
+
+                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D2_PLAYBACK);   //power off dac to hp and speaker out and auxout
+                                               
+
+
+                       break;
+               case SNDRV_PCM_STREAM_CAPTURE:
+
+                       Enable_ADC_Input_Source(codec,RT_WAVIN_L_MIC1|RT_WAVIN_R_MIC1,0);       //disable record source from mic1
+
+                       rt5621_ChangeCodecPowerStatus(codec,POWER_STATE_D2_RECORD);
+                       
+
+                       break;                  
+       }       
+}
+
+//#define RT5621_HIFI_RATES SNDRV_PCM_RATE_8000_48000
+#define RT5621_HIFI_RATES (SNDRV_PCM_RATE_44100) // zyy 20110704, playback and record use same sample rate
+
+#define RT5621_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
+               SNDRV_PCM_FMTBIT_S24_LE)
+
+struct snd_soc_dai_ops rt5621_hifi_ops = {
+       .hw_params = rt5621_pcm_hw_params,      
+       .set_fmt = rt5621_set_dai_fmt,
+       .set_sysclk = rt5621_set_dai_sysclk,
+       .set_pll = rt5621_set_dai_pll,
+       .prepare = rt5621_pcm_hw_prepare,
+       .shutdown = rt5621_shutdown,
+};
+
+struct snd_soc_dai_driver rt5621_dai = { 
+       .name = "RT5621 HiFi",
+       .playback = {
+               .stream_name = "HiFi Playback",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = RT5621_HIFI_RATES,
+               .formats = RT5621_FORMATS,
+       },
+       .capture = {
+               .stream_name = "HiFi Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rates = RT5621_HIFI_RATES,
+               .formats = RT5621_FORMATS,
+       },
+       .ops = &rt5621_hifi_ops,
+};
+
+static struct snd_soc_codec_driver soc_codec_dev_rt5621 = {
+       .probe =        rt5621_probe,
+       .remove = rt5621_remove,
+       .suspend = rt5621_suspend,
+       .resume = rt5621_resume,
+       .set_bias_level = rt5621_set_bias_level,
+       .reg_cache_size = RT5621_VENDOR_ID2 + 1,
+       .reg_word_size = sizeof(u16),
+       .reg_cache_default = rt5621_reg,
+       .volatile_register = rt5621_volatile_register,
+       .readable_register = rt5621_readable_register,
+       .reg_cache_step = 1,
+       .controls = rt5621_snd_controls,
+       .num_controls = ARRAY_SIZE(rt5621_snd_controls),
+};
+
+static const struct i2c_device_id rt5621_i2c_id[] = {
+       { "rt5621", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, rt5621_i2c_id);
+
+static int rt5621_i2c_probe(struct i2c_client *i2c,
+                   const struct i2c_device_id *id)
+{
+       struct rt5621_priv *rt5621;
+       int ret;
+
+       rt5621 = kzalloc(sizeof(struct rt5621_priv), GFP_KERNEL);
+       if (NULL == rt5621)
+               return -ENOMEM;
+
+       i2c_set_clientdata(i2c, rt5621);
+
+       ret = snd_soc_register_codec(&i2c->dev,
+               &soc_codec_dev_rt5621, &rt5621_dai, 1);
+       if (ret < 0)
+               kfree(rt5621);
+
+       return ret;
+}
+
+static __devexit int rt5621_i2c_remove(struct i2c_client *i2c)
+{
+       snd_soc_unregister_codec(&i2c->dev);
+       kfree(i2c_get_clientdata(i2c));
+       return 0;
+}
+
+struct i2c_driver rt5621_i2c_driver = {
+       .driver = {
+               .name = "RT5621",
+               .owner = THIS_MODULE,
+       },
+       .probe = rt5621_i2c_probe,
+       .remove   = __devexit_p(rt5621_i2c_remove),
+       .id_table = rt5621_i2c_id,
+};
+
+static int __init rt5621_modinit(void)
+{
+       return i2c_add_driver(&rt5621_i2c_driver);
+}
+module_init(rt5621_modinit);
+
+static void __exit rt5621_modexit(void)
+{
+       i2c_del_driver(&rt5621_i2c_driver);
+}
+module_exit(rt5621_modexit);
+
+MODULE_DESCRIPTION("ASoC RT5621 driver");
+MODULE_AUTHOR("Johnny Hsu <johnnyhsu@realtek.com>");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/rt5621.h b/sound/soc/codecs/rt5621.h
new file mode 100644 (file)
index 0000000..9c1459c
--- /dev/null
@@ -0,0 +1,515 @@
+/*
+ * rt5621.h  --  RT5621 ALSA SoC audio driver
+ *
+ * Copyright 2011 Realtek Microelectronics
+ * Author: Johnny Hsu <johnnyhsu@realtek.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __RT5621_H__
+#define __RT5621_H__
+
+#define RT5621_RESET                                           0X00                    //RESET CODEC TO DEFAULT
+#define RT5621_SPK_OUT_VOL                                     0X02                    //SPEAKER OUT VOLUME
+#define RT5621_HP_OUT_VOL                                      0X04                    //HEADPHONE OUTPUT VOLUME
+#define RT5621_MONO_AUX_OUT_VOL                                0X06                    //MONO OUTPUT/AUXOUT VOLUME
+#define RT5621_AUXIN_VOL                                       0X08                    //AUXIN VOLUME
+#define RT5621_LINE_IN_VOL                                     0X0A                    //LINE IN VOLUME
+#define RT5621_STEREO_DAC_VOL                          0X0C                    //STEREO DAC VOLUME
+#define RT5621_MIC_VOL                                         0X0E                    //MICROPHONE VOLUME
+#define RT5621_MIC_ROUTING_CTRL                                0X10                    //MIC ROUTING CONTROL
+#define RT5621_ADC_REC_GAIN                                    0X12                    //ADC RECORD GAIN
+#define RT5621_ADC_REC_MIXER                           0X14                    //ADC RECORD MIXER CONTROL
+#define RT5621_SOFT_VOL_CTRL_TIME                      0X16                    //SOFT VOLUME CONTROL TIME
+#define RT5621_OUTPUT_MIXER_CTRL                       0X1C                    //OUTPUT MIXER CONTROL
+#define RT5621_MIC_CTRL                                                0X22                    //MICROPHONE CONTROL
+#define        RT5621_AUDIO_INTERFACE                          0X34                    //AUDIO INTERFACE
+#define RT5621_STEREO_AD_DA_CLK_CTRL           0X36                    //STEREO AD/DA CLOCK CONTROL
+#define        RT5621_COMPANDING_CTRL                          0X38                    //COMPANDING CONTROL
+#define        RT5621_PWR_MANAG_ADD1                           0X3A                    //POWER MANAGMENT ADDITION 1
+#define RT5621_PWR_MANAG_ADD2                          0X3C                    //POWER MANAGMENT ADDITION 2
+#define RT5621_PWR_MANAG_ADD3                          0X3E                    //POWER MANAGMENT ADDITION 3
+#define RT5621_ADD_CTRL_REG                                    0X40                    //ADDITIONAL CONTROL REGISTER
+#define        RT5621_GLOBAL_CLK_CTRL_REG                      0X42                    //GLOBAL CLOCK CONTROL REGISTER
+#define RT5621_PLL_CTRL                                                0X44                    //PLL CONTROL
+#define RT5621_GPIO_OUTPUT_PIN_CTRL                    0X4A                    //GPIO OUTPUT PIN CONTROL
+#define RT5621_GPIO_PIN_CONFIG                         0X4C                    //GPIO PIN CONFIGURATION
+#define RT5621_GPIO_PIN_POLARITY                       0X4E                    //GPIO PIN POLARITY/TYPE        
+#define RT5621_GPIO_PIN_STICKY                         0X50                    //GPIO PIN STICKY       
+#define RT5621_GPIO_PIN_WAKEUP                         0X52                    //GPIO PIN WAKE UP
+#define RT5621_GPIO_PIN_STATUS                         0X54                    //GPIO PIN STATUS
+#define RT5621_GPIO_PIN_SHARING                                0X56                    //GPIO PIN SHARING
+#define        RT5621_OVER_TEMP_CURR_STATUS            0X58                    //OVER TEMPERATURE AND CURRENT STATUS
+#define RT5621_JACK_DET_CTRL                           0X5A                    //JACK DETECT CONTROL REGISTER
+#define RT5621_MISC_CTRL                                       0X5E                    //MISC CONTROL
+#define        RT5621_PSEDUEO_SPATIAL_CTRL                     0X60                    //PSEDUEO STEREO & SPATIAL EFFECT BLOCK CONTROL
+#define RT5621_EQ_CTRL                                         0X62                    //EQ CONTROL
+#define RT5621_EQ_MODE_ENABLE                          0X66                    //EQ MODE CHANGE ENABLE
+#define RT5621_AVC_CTRL                                                0X68                    //AVC CONTROL
+#define RT5621_HID_CTRL_INDEX                          0X6A                    //HIDDEN CONTROL INDEX PORT
+#define RT5621_HID_CTRL_DATA                           0X6C                    //HIDDEN CONTROL DATA PORT
+#define RT5621_VENDOR_ID1                              0x7C                    //VENDOR ID1
+#define RT5621_VENDOR_ID2                              0x7E                    //VENDOR ID2
+
+
+//global definition
+#define RT_L_MUTE                                              (0x1<<15)               //MUTE LEFT CONTROL BIT
+#define RT_L_ZC                                                        (0x1<<14)               //LEFT ZERO CROSS CONTROL BIT
+#define RT_L_SM                                                        (0x1<<13)               //LEFT SOFTMUTE CONTROL BIT
+#define RT_R_MUTE                                              (0x1<<7)                //MUTE RIGHT CONTROL BIT
+#define RT_R_ZC                                                        (0x1<<6)                //RIGHT ZERO CROSS CONTROL BIT
+#define RT_R_SM                                                        (0x1<<5)                //RIGHT SOFTMUTE CONTROL BIT
+#define RT_M_HP_MIXER                                  (0x1<<15)               //Mute source to HP Mixer
+#define RT_M_SPK_MIXER                                 (0x1<<14)               //Mute source to Speaker Mixer
+#define RT_M_MONO_MIXER                                        (0x1<<13)               //Mute source to Mono Mixer
+#define SPK_CLASS_AB                                           0
+#define SPK_CLASS_D                                                    1
+
+//Mic Routing Control(0x10)
+#define M_MIC1_TO_HP_MIXER                             (0x1<<15)               //Mute MIC1 to HP mixer
+#define M_MIC1_TO_SPK_MIXER                            (0x1<<14)               //Mute MiC1 to SPK mixer
+#define M_MIC1_TO_MONO_MIXER                   (0x1<<13)               //Mute MIC1 to MONO mixer
+#define MIC1_DIFF_INPUT_CTRL                   (0x1<<12)               //MIC1 different input control
+#define M_MIC2_TO_HP_MIXER                             (0x1<<7)                //Mute MIC2 to HP mixer
+#define M_MIC2_TO_SPK_MIXER                            (0x1<<6)                //Mute MiC2 to SPK mixer
+#define M_MIC2_TO_MONO_MIXER                   (0x1<<5)                //Mute MIC2 to MONO mixer
+#define MIC2_DIFF_INPUT_CTRL                   (0x1<<4)                //MIC2 different input control
+
+//ADC Record Gain(0x12)
+#define M_ADC_L_TO_HP_MIXER                            (0x1<<15)               //Mute left of ADC to HP Mixer
+#define M_ADC_R_TO_HP_MIXER                            (0x1<<14)               //Mute right of ADC to HP Mixer
+#define M_ADC_L_TO_MONO_MIXER                  (0x1<<13)               //Mute left of ADC to MONO Mixer
+#define M_ADC_R_TO_MONO_MIXER                  (0x1<<12)               //Mute right of ADC to MONO Mixer
+#define ADC_L_GAIN_MASK                                        (0x1f<<7)               //ADC Record Gain Left channel Mask
+#define ADC_L_ZC_DET                                   (0x1<<6)                //ADC Zero-Cross Detector Control
+#define ADC_R_ZC_DET                                   (0x1<<5)                //ADC Zero-Cross Detector Control
+#define ADC_R_GAIN_MASK                                        (0x1f<<0)               //ADC Record Gain Right channel Mask
+
+//ADC Input Mixer Control(0x14)
+#define M_MIC1_TO_ADC_L_MIXER                          (0x1<<14)               //Mute mic1 to left channel of ADC mixer
+#define M_MIC2_TO_ADC_L_MIXER                          (0x1<<13)               //Mute mic2 to left channel of ADC mixer
+#define M_LINEIN_L_TO_ADC_L_MIXER                      (0x1<<12)               //Mute line In left channel to left channel of ADC mixer
+#define M_AUXIN_L_TO_ADC_L_MIXER                       (0x1<<11)               //Mute aux In left channel to left channel of ADC mixer
+#define M_HPMIXER_L_TO_ADC_L_MIXER                     (0x1<<10)               //Mute HP mixer left channel to left channel of ADC mixer
+#define M_SPKMIXER_L_TO_ADC_L_MIXER                    (0x1<<9)                //Mute SPK mixer left channel to left channel of ADC mixer
+#define M_MONOMIXER_L_TO_ADC_L_MIXER           (0x1<<8)                //Mute MONO mixer left channel to left channel of ADC mixer
+#define M_MIC1_TO_ADC_R_MIXER                          (0x1<<6)                //Mute mic1 to right channel of ADC mixer
+#define M_MIC2_TO_ADC_R_MIXER                          (0x1<<5)                //Mute mic2 to right channel of ADC mixer
+#define M_LINEIN_R_TO_ADC_R_MIXER                      (0x1<<4)                //Mute lineIn right channel to right channel of ADC mixer
+#define M_AUXIN_R_TO_ADC_R_MIXER                       (0x1<<3)                //Mute aux In right channel to right channel of ADC mixer
+#define M_HPMIXER_R_TO_ADC_R_MIXER                     (0x1<<2)                //Mute HP mixer right channel to right channel of ADC mixer
+#define M_SPKMIXER_R_TO_ADC_R_MIXER                    (0x1<<1)                //Mute SPK mixer right channel to right channel of ADC mixer
+#define M_MONOMIXER_R_TO_ADC_R_MIXER           (0x1<<0)                //Mute MONO mixer right channel to right channel of ADC mixer
+
+//Output Mixer Control(0x1C)
+#define        SPKOUT_N_SOUR_MASK                                      (0x3<<14)       
+#define        SPKOUT_N_SOUR_LN                                        (0x2<<14)
+#define        SPKOUT_N_SOUR_RP                                        (0x1<<14)
+#define        SPKOUT_N_SOUR_RN                                        (0x0<<14)
+#define SPK_OUTPUT_CLASS_AB                                    (0x0<<13)
+#define SPK_OUTPUT_CLASS_D                                     (0x1<<13)
+#define SPK_CLASS_AB_S_AMP                                     (0x0<<12)
+#define SPK_CALSS_AB_W_AMP                                     (0x1<<12)
+#define SPKOUT_INPUT_SEL_MASK                          (0x3<<10)
+#define SPKOUT_INPUT_SEL_MONOMIXER                     (0x3<<10)
+#define SPKOUT_INPUT_SEL_SPKMIXER                      (0x2<<10)
+#define SPKOUT_INPUT_SEL_HPMIXER                       (0x1<<10)
+#define SPKOUT_INPUT_SEL_VMID                          (0x0<<10)
+#define HPL_INPUT_SEL_HPLMIXER                         (0x1<<9)
+#define HPR_INPUT_SEL_HPRMIXER                         (0x1<<8)        
+#define MONO_AUX_INPUT_SEL_MASK                                (0x3<<6)
+#define MONO_AUX_INPUT_SEL_MONO                                (0x3<<6)
+#define MONO_AUX_INPUT_SEL_SPK                         (0x2<<6)
+#define MONO_AUX_INPUT_SEL_HP                          (0x1<<6)
+#define MONO_AUX_INPUT_SEL_VMID                                (0x0<<6)
+
+//Micphone Control define(0x22)
+#define MIC1           1
+#define MIC2           2
+#define MIC_BIAS_90_PRECNET_AVDD       1
+#define        MIC_BIAS_75_PRECNET_AVDD        2
+
+#define MIC1_BOOST_CTRL_MASK           (0x3<<10)
+#define MIC1_BOOST_CTRL_BYPASS         (0x0<<10)
+#define MIC1_BOOST_CTRL_20DB           (0x1<<10)
+#define MIC1_BOOST_CTRL_30DB           (0x2<<10)
+#define MIC1_BOOST_CTRL_40DB           (0x3<<10)
+
+#define MIC2_BOOST_CTRL_MASK           (0x3<<8)
+#define MIC2_BOOST_CTRL_BYPASS         (0x0<<8)
+#define MIC2_BOOST_CTRL_20DB           (0x1<<8)
+#define MIC2_BOOST_CTRL_30DB           (0x2<<8)
+#define MIC2_BOOST_CTRL_40DB           (0x3<<8)
+
+#define MICBIAS_VOLT_CTRL_MASK         (0x1<<5)
+#define MICBIAS_VOLT_CTRL_90P          (0x0<<5)
+#define MICBIAS_VOLT_CTRL_75P          (0x1<<5)
+
+#define MICBIAS_SHORT_CURR_DET_MASK            (0x3)
+#define MICBIAS_SHORT_CURR_DET_600UA   (0x0)
+#define MICBIAS_SHORT_CURR_DET_1200UA  (0x1)
+#define MICBIAS_SHORT_CURR_DET_1800UA  (0x2)
+
+//Audio Interface(0x34)                        
+#define SDP_MASTER_MODE                                (0x0<<15)               //Main I2S interface select Master mode
+#define SDP_SLAVE_MODE                         (0x1<<15)               //Main I2S interface select Slave mode
+#define I2S_PCM_MODE                           (0x1<<14)               //PCM           0:mode A                                ,1:mode B                                                                                                       
+#define MAIN_I2S_BCLK_POL_CTRL         (0x1<<7)                //0:Normal 1:Invert
+#define ADC_DATA_L_R_SWAP                      (0x1<<5)                //0:ADC data appear at left phase of LRCK
+                                                                                                       //1:ADC data appear at right phase of LRCK
+#define DAC_DATA_L_R_SWAP                      (0x1<<4)                //0:DAC data appear at left phase of LRCK
+                                                                                                       //1:DAC data appear at right phase of LRCK      
+//Data Length Slection
+#define I2S_DL_MASK                            (0x3<<2)                //main i2s Data Length mask     
+#define I2S_DL_16                              (0x0<<2)                //16 bits
+#define I2S_DL_20                              (0x1<<2)                //20 bits
+#define        I2S_DL_24                               (0x2<<2)                //24 bits
+#define I2S_DL_32                              (0x3<<2)                //32 bits
+                                                                                                       
+//PCM Data Format Selection
+#define I2S_DF_MASK                            (0x3)                   //main i2s Data Format mask
+#define I2S_DF_I2S                             (0x0)                   //I2S FORMAT 
+#define I2S_DF_RIGHT                   (0x1)                   //RIGHT JUSTIFIED format
+#define        I2S_DF_LEFT                             (0x2)                   //LEFT JUSTIFIED  format
+#define I2S_DF_PCM                             (0x3)                   //PCM format
+
+//Stereo AD/DA Clock Control(0x36h)
+#define I2S_PRE_DIV_MASK               (0x7<<12)                       
+#define I2S_PRE_DIV_1                  (0x0<<12)                       //DIV 1
+#define I2S_PRE_DIV_2                  (0x1<<12)                       //DIV 2
+#define I2S_PRE_DIV_4                  (0x2<<12)                       //DIV 4
+#define I2S_PRE_DIV_8                  (0x3<<12)                       //DIV 8
+#define I2S_PRE_DIV_16                 (0x4<<12)                       //DIV 16
+#define I2S_PRE_DIV_32                 (0x5<<12)                       //DIV 32
+
+#define I2S_SCLK_DIV_MASK              (0x7<<9)                        
+#define I2S_SCLK_DIV_1                 (0x0<<9)                        //DIV 1
+#define I2S_SCLK_DIV_2                 (0x1<<9)                        //DIV 2
+#define I2S_SCLK_DIV_3                 (0x2<<9)                        //DIV 3
+#define I2S_SCLK_DIV_4                 (0x3<<9)                        //DIV 4
+#define I2S_SCLK_DIV_6                 (0x4<<9)                        //DIV 6
+#define I2S_SCLK_DIV_8                 (0x5<<9)                        //DIV 8
+#define I2S_SCLK_DIV_12                        (0x6<<9)                        //DIV 12
+#define I2S_SCLK_DIV_16                        (0x7<<9)                        //DIV 16
+
+#define I2S_WCLK_DIV_PRE_MASK          (0xF<<5)                        
+#define I2S_WCLK_PRE_DIV_1                     (0x0<<5)                        //DIV 1
+#define I2S_WCLK_PRE_DIV_2                     (0x1<<5)                        //DIV 2
+#define I2S_WCLK_PRE_DIV_3                     (0x2<<5)                        //DIV 3
+#define I2S_WCLK_PRE_DIV_4                     (0x3<<5)                        //DIV 4
+#define I2S_WCLK_PRE_DIV_5                     (0x4<<5)                        //DIV 5
+#define I2S_WCLK_PRE_DIV_6                     (0x5<<5)                        //DIV 6
+#define I2S_WCLK_PRE_DIV_7                     (0x6<<5)                        //DIV 7
+#define I2S_WCLK_PRE_DIV_8                     (0x7<<5)                        //DIV 8
+//........................
+
+#define I2S_WCLK_DIV_MASK              (0x7<<2)                        
+#define I2S_WCLK_DIV_2                 (0x0<<2)                        //DIV 2
+#define I2S_WCLK_DIV_4                 (0x1<<2)                        //DIV 4
+#define I2S_WCLK_DIV_8                 (0x2<<2)                        //DIV 8
+#define I2S_WCLK_DIV_16                        (0x3<<2)                        //DIV 16
+#define I2S_WCLK_DIV_32                        (0x4<<2)                        //DIV 32
+
+#define ADDA_FILTER_CLK_SEL_256FS      (0<<1)                  //256FS
+#define ADDA_FILTER_CLK_SEL_384FS      (1<<1)                  //384FS
+
+#define ADDA_OSR_SEL_64FS      (0)                                             //64FS
+#define ADDA_OSR_SEL_128FS     (1)                                             //128FS
+
+//Power managment addition 1 (0x3A),0:Disable,1:Enable
+#define PWR_MAIN_I2S_EN                                (0x1<<15)
+#define PWR_ZC_DET_PD_EN                       (0x1<<14)       
+#define PWR_MIC1_BIAS_EN                       (0x1<<11)
+#define PWR_SHORT_CURR_DET_EN          (0x1<<10)
+#define PWR_SOFTGEN_EN                         (0x1<<8)
+#define        PWR_DEPOP_BUF_HP                        (0x1<<6)
+#define        PWR_HP_OUT_AMP                          (0x1<<5)
+#define        PWR_HP_OUT_ENH_AMP                      (0x1<<4)
+#define PWR_DEPOP_BUF_AUX                      (0x1<<2)
+#define PWR_AUX_OUT_AMP                                (0x1<<1)
+#define PWR_AUX_OUT_ENH_AMP                    (0x1)
+
+
+//Power managment addition 2(0x3C),0:Disable,1:Enable
+#define PWR_CLASS_AB                           (0x1<<15)
+#define PWR_CLASS_D                                    (0x1<<14)
+#define PWR_VREF                                       (0x1<<13)
+#define PWR_PLL                                                (0x1<<12)
+#define PWR_DAC_REF_CIR                                (0x1<<10)
+#define PWR_L_DAC_CLK                          (0x1<<9)
+#define PWR_R_DAC_CLK                          (0x1<<8)
+#define PWR_L_ADC_CLK_GAIN                     (0x1<<7)
+#define PWR_R_ADC_CLK_GAIN                     (0x1<<6)
+#define PWR_L_HP_MIXER                         (0x1<<5)
+#define PWR_R_HP_MIXER                         (0x1<<4)
+#define PWR_SPK_MIXER                          (0x1<<3)
+#define PWR_MONO_MIXER                         (0x1<<2)
+#define PWR_L_ADC_REC_MIXER                    (0x1<<1)
+#define PWR_R_ADC_REC_MIXER                    (0x1)
+
+//Power managment addition 3(0x3E),0:Disable,1:Enable
+#define PWR_MAIN_BIAS                          (0x1<<15)
+#define PWR_AUXOUT_L_VOL_AMP           (0x1<<14)
+#define PWR_AUXOUT_R_VOL_AMP           (0x1<<13)
+#define PWR_SPK_OUT                                    (0x1<<12)
+#define PWR_HP_L_OUT_VOL                       (0x1<<10)
+#define PWR_HP_R_OUT_VOL                       (0x1<<9)
+#define PWR_LINEIN_L_VOL                       (0x1<<7)
+#define PWR_LINEIN_R_VOL                       (0x1<<6)
+#define PWR_AUXIN_L_VOL                                (0x1<<5)
+#define PWR_AUXIN_R_VOL                                (0x1<<4)
+#define PWR_MIC1_FUN_CTRL                      (0x1<<3)
+#define PWR_MIC2_FUN_CTRL                      (0x1<<2)
+#define PWR_MIC1_BOOST_MIXER           (0x1<<1)
+#define PWR_MIC2_BOOST_MIXER           (0x1)
+
+
+//Additional Control Register(0x40)
+#define AUXOUT_SEL_DIFF                                        (0x1<<15)       //Differential Mode
+#define AUXOUT_SEL_SE                                  (0x1<<15)       //Single-End Mode
+
+#define SPK_AB_AMP_CTRL_MASK                   (0x7<<12)
+#define SPK_AB_AMP_CTRL_RATIO_225              (0x0<<12)               //2.25 Vdd
+#define SPK_AB_AMP_CTRL_RATIO_200              (0x1<<12)               //2.00 Vdd
+#define SPK_AB_AMP_CTRL_RATIO_175              (0x2<<12)               //1.75 Vdd
+#define SPK_AB_AMP_CTRL_RATIO_150              (0x3<<12)               //1.50 Vdd
+#define SPK_AB_AMP_CTRL_RATIO_125              (0x4<<12)               //1.25 Vdd      
+#define SPK_AB_AMP_CTRL_RATIO_100              (0x5<<12)               //1.00 Vdd
+
+#define SPK_D_AMP_CTRL_MASK                            (0x3<<10)
+#define SPK_D_AMP_CTRL_RATIO_175               (0x0<<10)               //1.75 Vdd
+#define SPK_D_AMP_CTRL_RATIO_150               (0x1<<10)               //1.50 Vdd      
+#define SPK_D_AMP_CTRL_RATIO_125               (0x2<<10)               //1.25 Vdd
+#define SPK_D_AMP_CTRL_RATIO_100               (0x3<<10)               //1.00 Vdd
+
+#define STEREO_DAC_HI_PASS_FILTER_EN   (0x1<<9)                //Stereo DAC high pass filter enable
+#define STEREO_ADC_HI_PASS_FILTER_EN   (0x1<<8)                //Stereo ADC high pass filter enable
+
+#define DIG_VOL_BOOST_MASK                             (0x3<<4)                //Digital volume Boost mask
+#define DIG_VOL_BOOST_0DB                              (0x0<<4)                //Digital volume Boost 0DB
+#define DIG_VOL_BOOST_6DB                              (0x1<<4)                //Digital volume Boost 6DB
+#define DIG_VOL_BOOST_12DB                             (0x2<<4)                //Digital volume Boost 12DB
+#define DIG_VOL_BOOST_18DB                             (0x3<<4)                //Digital volume Boost 18DB
+
+
+//Global Clock Control Register(0x42)
+#define SYSCLK_SOUR_SEL_MASK                   (0x1<<15)
+#define SYSCLK_SOUR_SEL_MCLK                   (0x0<<15)               //system Clock source from MCLK
+#define SYSCLK_SOUR_SEL_PLL                            (0x1<<15)               //system Clock source from PLL
+#define PLLCLK_SOUR_SEL_MCLK                   (0x0<<14)               //PLL clock source from MCLK
+#define PLLCLK_SOUR_SEL_BITCLK                 (0x1<<14)               //PLL clock source from BITCLK
+
+#define PLLCLK_DIV_RATIO_MASK                  (0x3<<1)                
+#define PLLCLK_DIV_RATIO_DIV1                  (0x0<<1)                //DIV 1
+#define PLLCLK_DIV_RATIO_DIV2                  (0x1<<1)                //DIV 2
+#define PLLCLK_DIV_RATIO_DIV4                  (0x2<<1)                //DIV 4
+#define PLLCLK_DIV_RATIO_DIV8                  (0x3<<1)                //DIV 8
+
+#define PLLCLK_PRE_DIV1                                        (0x0)                   //DIV 1
+#define PLLCLK_PRE_DIV2                                        (0x1)                   //DIV 2
+
+//PLL Control(0x44)
+
+#define PLL_CTRL_M_VAL(m)              ((m)&0xf)
+#define PLL_CTRL_K_VAL(k)              (((k)&0x7)<<4)
+#define PLL_CTRL_N_VAL(n)              (((n)&0xff)<<8)
+
+//GPIO Pin Configuration(0x4C)
+#define GPIO_PIN_MASK                          (0x1<<1)
+#define GPIO_PIN_SET_INPUT                     (0x1<<1)
+#define GPIO_PIN_SET_OUTPUT                    (0x0<<1)
+
+//Pin Sharing(0x56)
+#define LINEIN_L_PIN_SHARING           (0x1<<15)
+#define LINEIN_L_PIN_AS_LINEIN_L       (0x0<<15)
+#define LINEIN_L_PIN_AS_JD1                    (0x1<<15)
+
+#define LINEIN_R_PIN_SHARING           (0x1<<14)
+#define LINEIN_R_PIN_AS_LINEIN_R       (0x0<<14)
+#define LINEIN_R_PIN_AS_JD2                    (0x1<<14)
+
+#define GPIO_PIN_SHARING                       (0x3)
+#define GPIO_PIN_AS_GPIO                       (0x0)
+#define GPIO_PIN_AS_IRQOUT                     (0x1)
+#define GPIO_PIN_AS_PLLOUT                     (0x3)
+
+//Jack Detect Control Register(0x5A)
+#define JACK_DETECT_MASK                       (0x3<<14)
+#define JACK_DETECT_USE_JD2                    (0x3<<14)
+#define JACK_DETECT_USE_JD1                    (0x2<<14)
+#define JACK_DETECT_USE_GPIO           (0x1<<14)
+#define JACK_DETECT_OFF                                (0x0<<14)
+
+#define        SPK_EN_IN_HI                            (0x1<<11)
+#define AUX_R_EN_IN_HI                         (0x1<<10)
+#define AUX_L_EN_IN_HI                         (0x1<<9)
+#define HP_EN_IN_HI                                    (0x1<<8)
+#define        SPK_EN_IN_LO                            (0x1<<7)
+#define AUX_R_EN_IN_LO                         (0x1<<6)
+#define AUX_L_EN_IN_LO                         (0x1<<5)
+#define HP_EN_IN_LO                                    (0x1<<4)
+
+////MISC CONTROL(0x5E)
+#define DISABLE_FAST_VREG                      (0x1<<15)
+#define SPK_CLASS_AB_OC_PD                     (0x1<<13)
+#define SPK_CLASS_AB_OC_DET                    (0x1<<12)
+#define HP_DEPOP_MODE3_EN                      (0x1<<10)
+#define HP_DEPOP_MODE2_EN                      (0x1<<9)
+#define HP_DEPOP_MODE1_EN                      (0x1<<8)
+#define AUXOUT_DEPOP_MODE3_EN          (0x1<<6)
+#define AUXOUT_DEPOP_MODE2_EN          (0x1<<5)
+#define AUXOUT_DEPOP_MODE1_EN          (0x1<<4)
+#define M_DAC_L_INPUT                          (0x1<<3)
+#define M_DAC_R_INPUT                          (0x1<<2)
+#define IRQOUT_INV_CTRL                                (0x1<<0)
+
+//Psedueo Stereo & Spatial Effect Block Control(0x60)
+#define SPATIAL_CTRL_EN                                (0x1<<15)
+#define ALL_PASS_FILTER_EN                     (0x1<<14)
+#define PSEUDO_STEREO_EN                       (0x1<<13)
+#define STEREO_EXPENSION_EN                    (0x1<<12)
+
+#define GAIN_3D_PARA_L_MASK                    (0x7<<9)
+#define GAIN_3D_PARA_L_1_00                    (0x0<<9)
+#define GAIN_3D_PARA_L_1_25                    (0x1<<9)
+#define GAIN_3D_PARA_L_1_50                    (0x2<<9)
+#define GAIN_3D_PARA_L_1_75                    (0x3<<9)
+#define GAIN_3D_PARA_L_2_00                    (0x4<<9)
+
+#define GAIN_3D_PARA_R_MASK                    (0x7<<6)
+#define GAIN_3D_PARA_R_1_00                    (0x0<<6)
+#define GAIN_3D_PARA_R_1_25                    (0x1<<6)
+#define GAIN_3D_PARA_R_1_50                    (0x2<<6)
+#define GAIN_3D_PARA_R_1_75                    (0x3<<6)
+#define GAIN_3D_PARA_R_2_00                    (0x4<<6)
+
+#define RATIO_3D_L_MASK                                (0x3<<4)
+#define RATIO_3D_L_0_0                         (0x0<<4)
+#define RATIO_3D_L_0_66                                (0x1<<4)
+#define RATIO_3D_L_1_0                         (0x2<<4)
+
+#define RATIO_3D_R_MASK                                (0x3<<2)
+#define RATIO_3D_R_0_0                         (0x0<<2)
+#define RATIO_3D_R_0_66                                (0x1<<2)
+#define RATIO_3D_R_1_0                         (0x2<<2)
+
+#define APF_MASK                                       (0x3)
+#define APF_FOR_48K                                    (0x3)
+#define APF_FOR_44_1K                          (0x2)
+#define APF_FOR_32K                                    (0x1)
+
+//EQ CONTROL(0x62)
+
+#define EN_HW_EQ_BLK                   (0x1<<15)               //HW EQ block control
+#define EN_HW_EQ_HPF_MODE              (0x1<<14)               //High Frequency shelving filter mode
+#define EN_HW_EQ_SOUR                  (0x1<<11)               //0:DAC PATH,1:ADC PATH
+#define EN_HW_EQ_HPF                   (0x1<<4)                //EQ High Pass Filter Control
+#define EN_HW_EQ_BP3                   (0x1<<3)                //EQ Band-3 Control
+#define EN_HW_EQ_BP2                   (0x1<<2)                //EQ Band-2 Control
+#define EN_HW_EQ_BP1                   (0x1<<1)                //EQ Band-1 Control
+#define EN_HW_EQ_LPF                   (0x1<<0)                //EQ Low Pass Filter Control
+
+//EQ Mode Change Enable(0x66)
+#define EQ_HPF_CHANGE_EN               (0x1<<4)                //EQ High Pass Filter Mode Change Enable
+#define EQ_BP3_CHANGE_EN               (0x1<<3)                //EQ Band-3 Pass Filter Mode Change Enable
+#define EQ_BP2_CHANGE_EN               (0x1<<2)                //EQ Band-2 Pass Filter Mode Change Enable
+#define EQ_BP1_CHANGE_EN               (0x1<<1)                //EQ Band-1 Pass Filter Mode Change Enable
+#define EQ_LPF_CHANGE_EN               (0x1<<0)                //EQ Low Pass Filter Mode Change Enable
+
+
+//AVC Control(0x68)
+#define AVC_ENABLE                             (0x1<<15)
+#define AVC_TARTGET_SEL_MASK   (0x1<<14)
+#define AVC_TARTGET_SEL_R              (0x1<<14)
+#define AVC_TARTGET_SEL_L              (0x0<<14)
+
+
+#define RT5621_PLL_FR_MCLK                     0
+#define RT5621_PLL_FR_BCLK                     1
+
+
+#define REALTEK_HWDEP 0
+
+//WaveOut channel for realtek codec
+enum 
+{
+       RT_WAVOUT_SPK                           =(0x1<<0),
+       RT_WAVOUT_SPK_R                         =(0x1<<1),
+       RT_WAVOUT_SPK_L                         =(0x1<<2),
+       RT_WAVOUT_HP                            =(0x1<<3),
+       RT_WAVOUT_HP_R                          =(0x1<<4),
+       RT_WAVOUT_HP_L                          =(0x1<<5),      
+       RT_WAVOUT_MONO                          =(0x1<<6),
+       RT_WAVOUT_AUXOUT                        =(0x1<<7),
+       RT_WAVOUT_AUXOUT_R                      =(0x1<<8),
+       RT_WAVOUT_AUXOUT_L                      =(0x1<<9),
+       RT_WAVOUT_LINEOUT                       =(0x1<<10),
+       RT_WAVOUT_LINEOUT_R                     =(0x1<<11),
+       RT_WAVOUT_LINEOUT_L                     =(0x1<<12),     
+       RT_WAVOUT_DAC                           =(0x1<<13),             
+       RT_WAVOUT_ALL_ON                        =(0x1<<14),
+};
+
+//WaveIn channel for realtek codec
+enum
+{
+       RT_WAVIN_R_MONO_MIXER           =(0x1<<0),
+       RT_WAVIN_R_SPK_MIXER            =(0x1<<1),
+       RT_WAVIN_R_HP_MIXER                     =(0x1<<2),
+       RT_WAVIN_R_PHONE                        =(0x1<<3),
+       RT_WAVIN_R_AUXIN                        =(0x1<<3),      
+       RT_WAVIN_R_LINE_IN                      =(0x1<<4),
+       RT_WAVIN_R_MIC2                         =(0x1<<5),
+       RT_WAVIN_R_MIC1                         =(0x1<<6),
+
+       RT_WAVIN_L_MONO_MIXER           =(0x1<<8),
+       RT_WAVIN_L_SPK_MIXER            =(0x1<<9),
+       RT_WAVIN_L_HP_MIXER                     =(0x1<<10),
+       RT_WAVIN_L_PHONE                        =(0x1<<11),
+       RT_WAVIN_L_AUXIN                        =(0x1<<11),
+       RT_WAVIN_L_LINE_IN                      =(0x1<<12),
+       RT_WAVIN_L_MIC2                         =(0x1<<13),
+       RT_WAVIN_L_MIC1                         =(0x1<<14),
+};
+
+enum 
+{
+       POWER_STATE_D0=0,
+       POWER_STATE_D1,
+       POWER_STATE_D1_PLAYBACK,
+       POWER_STATE_D1_RECORD,
+       POWER_STATE_D2,
+       POWER_STATE_D2_PLAYBACK,
+       POWER_STATE_D2_RECORD,
+       POWER_STATE_D3,
+       POWER_STATE_D4
+
+}; 
+
+#if REALTEK_HWDEP
+
+struct rt56xx_reg_state
+{
+       unsigned int reg_index;
+       unsigned int reg_value;
+};
+
+struct rt56xx_cmd
+{
+       size_t number;
+       struct rt56xx_reg_state __user *buf;            
+};
+
+enum 
+{
+       RT_READ_CODEC_REG_IOCTL = _IOR('R', 0x01, struct rt56xx_cmd),
+       RT_READ_ALL_CODEC_REG_IOCTL = _IOR('R', 0x02, struct rt56xx_cmd),
+       RT_WRITE_CODEC_REG_IOCTL = _IOW('R', 0x03, struct rt56xx_cmd),
+};
+
+#endif
+
+#endif /* __RT5621_H__ */
index ea09a47038a5f338033d666a5b5a1498b835decd..0790d53ab6202b73882cbff6aeed37a9e3a669b7 100755 (executable)
@@ -1331,16 +1331,9 @@ static int rt5631_add_widgets(struct snd_soc_codec *codec)
        return 0;\r
 }\r
 \r
-static int voltab[2][16] = \r
-{\r
-    //spk\r
-    {0x27, 0x1b, 0x18, 0x15, 0x13, 0x11, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06},\r
-    //hp\r
-    {0x1f, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},\r
-};\r
 static int gvolume = 0;\r
-#if 1\r
 \r
+#if 1\r
 static int get_vol(int max, int min, int stage_num, int stage)\r
 {\r
        int ret, step=((max-min)<<8)/(stage_num-1);\r
@@ -1412,6 +1405,14 @@ static void rt5631_set_eq(int on)
 \r
 #else\r
 \r
+static int voltab[2][16] =\r
+{\r
+    //spk\r
+    {0x27, 0x1b, 0x18, 0x15, 0x13, 0x11, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06},\r
+    //hp\r
+    {0x1f, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},\r
+};\r
+\r
 static void rt5631_set_volume(int vollevel)\r
 {\r
        struct snd_soc_codec *codec = rt5631_codec;\r
@@ -1806,6 +1807,7 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
        return ret;\r
 }\r
 \r
+#if defined(CONFIG_ADJUST_VOL_BY_CODEC)\r
 static int rt5631_trigger(struct snd_pcm_substream *substream, int status, struct snd_soc_dai *dai)\r
 {\r
        //DBG("rt5631_trigger\n");\r
@@ -1826,6 +1828,7 @@ static int rt5631_trigger(struct snd_pcm_substream *substream, int status, struc
 \r
        return 0;\r
 }\r
+#endif\r
 \r
 static ssize_t rt5631_index_reg_show(struct device *dev,\r
        struct device_attribute *attr, char *buf)\r
@@ -2052,17 +2055,17 @@ void codec_set_spk(bool on)
 \r
        if(on){\r
                DBG("snd_soc_dapm_enable_pin\n");\r
-               snd_soc_dapm_enable_pin(codec, "Headphone Jack");\r
-               snd_soc_dapm_enable_pin(codec, "Ext Spk");\r
+               snd_soc_dapm_enable_pin(&codec->dapm, "Headphone Jack");\r
+               snd_soc_dapm_enable_pin(&codec->dapm, "Ext Spk");\r
        }\r
        else{\r
 \r
                DBG("snd_soc_dapm_disable_pin\n");\r
-               snd_soc_dapm_disable_pin(codec, "Headphone Jack");\r
-               snd_soc_dapm_disable_pin(codec, "Ext Spk");\r
+               snd_soc_dapm_disable_pin(&codec->dapm, "Headphone Jack");\r
+               snd_soc_dapm_disable_pin(&codec->dapm, "Ext Spk");\r
        }\r
 \r
-       snd_soc_dapm_sync(codec);\r
+       snd_soc_dapm_sync(&codec->dapm);\r
 \r
        return;\r
 }\r
index d7170f1381aa758084834de1f7eae0532d7e00a7..89bbc7dd242e37b529f26ef86770018ffe41da26 100644 (file)
 #include <sound/pcm_params.h>
 #include <sound/tlv.h>
 #include <sound/soc.h>
+#include <sound/soc-dapm.h>
 #include <sound/initval.h>
 
+#include <mach/iomux.h>
+#include <mach/gpio.h>
+
 #include "wm8988.h"
 
+#include <linux/proc_fs.h>
+#include <linux/gpio.h>
+
+#if 0
+#define DBG(x...) printk(KERN_INFO x)
+#else
+#define DBG(x...) do { } while (0)
+#endif
+
 /*
  * wm8988 register cache
  * We can't read the WM8988 register space when we
@@ -53,6 +66,8 @@ struct wm8988_priv {
        unsigned int sysclk;
        enum snd_soc_control_type control_type;
        struct snd_pcm_hw_constraint_list *sysclk_constraints;
+       int is_startup;         // gModify.Add
+       int is_biason;
 };
 
 
@@ -190,6 +205,8 @@ static int wm8988_lrc_control(struct snd_soc_dapm_widget *w,
        else
                adctl2 |= 0x4;
 
+       DBG("Enter::%s----%d, adctl2 = %x\n",__FUNCTION__,__LINE__,adctl2);
+       
        return snd_soc_write(codec, WM8988_ADCTL2, adctl2);
 }
 
@@ -290,8 +307,9 @@ static const struct snd_soc_dapm_widget wm8988_dapm_widgets[] = {
        SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8988_PWR1, 2, 0),
        SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8988_PWR1, 3, 0),
 
-       SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8988_PWR2, 7, 0),
-       SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8988_PWR2, 8, 0),
+       /* gModify.Cmmt Implement when suspend/startup */
+       /*SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8988_PWR2, 7, 0),*/
+       /*SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8988_PWR2, 8, 0),*/
 
        SND_SOC_DAPM_MIXER("Left Mixer", SND_SOC_NOPM, 0, 0,
                &wm8988_left_mixer_controls[0],
@@ -477,7 +495,7 @@ static struct snd_pcm_hw_constraint_list constraints_112896 = {
 };
 
 static unsigned int rates_12[] = {
-       8000, 11025, 12000, 16000, 22050, 2400, 32000, 41100, 48000,
+       8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
        48000, 88235, 96000,
 };
 
@@ -495,6 +513,8 @@ static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai,
        struct snd_soc_codec *codec = codec_dai->codec;
        struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec);
 
+    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+               
        switch (freq) {
        case 11289600:
        case 18432000:
@@ -575,6 +595,8 @@ static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai,
                return -EINVAL;
        }
 
+       DBG("Enter::%s----%d  iface=%x\n",__FUNCTION__,__LINE__,iface);
+
        snd_soc_write(codec, WM8988_IFACE, iface);
        return 0;
 }
@@ -585,6 +607,17 @@ static int wm8988_pcm_startup(struct snd_pcm_substream *substream,
        struct snd_soc_codec *codec = dai->codec;
        struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec);
 
+       if (!wm8988->is_startup) {
+               wm8988->is_startup = 1;
+               snd_soc_write(codec, WM8988_PWR1, 0xfc);
+               gpio_direction_output(RK29_PIN6_PB5, GPIO_LOW);
+               mdelay(100);            // Discharge C310
+               snd_soc_write(codec, WM8988_PWR2, 0x1e0);
+               gpio_direction_output(RK29_PIN6_PB5, GPIO_HIGH);
+       }
+
+       DBG("Enter::%s----%d  wm8988->sysclk=%d\n",__FUNCTION__,__LINE__,wm8988->sysclk); 
+
        /* The set of sample rates that can be supported depends on the
         * MCLK supplied to the CODEC - enforce this.
         */
@@ -639,6 +672,8 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream,
                break;
        }
 
+       DBG("Enter::%s----%d  iface=%x srate =%x rate=%d\n",__FUNCTION__,__LINE__,iface,srate,params_rate(params));
+
        /* set iface & srate */
        snd_soc_write(codec, WM8988_IFACE, iface);
        if (coeff >= 0)
@@ -653,6 +688,8 @@ static int wm8988_mute(struct snd_soc_dai *dai, int mute)
        struct snd_soc_codec *codec = dai->codec;
        u16 mute_reg = snd_soc_read(codec, WM8988_ADCDAC) & 0xfff7;
 
+       DBG("Enter::%s----%d--mute=%d\n",__FUNCTION__,__LINE__,mute);
+
        if (mute)
                snd_soc_write(codec, WM8988_ADCDAC, mute_reg | 0x8);
        else
@@ -663,13 +700,22 @@ static int wm8988_mute(struct snd_soc_dai *dai, int mute)
 static int wm8988_set_bias_level(struct snd_soc_codec *codec,
                                 enum snd_soc_bias_level level)
 {
+       struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec);
        u16 pwr_reg = snd_soc_read(codec, WM8988_PWR1) & ~0x1c1;
 
+       DBG("Enter::%s----%d level =%d\n",__FUNCTION__,__LINE__,level);
+
        switch (level) {
        case SND_SOC_BIAS_ON:
+               wm8988->is_biason = 1;
                break;
 
        case SND_SOC_BIAS_PREPARE:
+               if (wm8988->is_startup && wm8988->is_biason) {
+                       snd_soc_write(codec, WM8988_PWR2, 0x0);
+                       wm8988->is_startup = 0;
+                       wm8988->is_biason = 0;
+               }
                /* VREF, VMID=2x50k, digital enabled */
                snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x00c0);
                break;
@@ -709,7 +755,7 @@ static struct snd_soc_dai_ops wm8988_ops = {
 };
 
 static struct snd_soc_dai_driver wm8988_dai = {
-       .name = "wm8988-hifi",
+       .name = "WM8988 HiFi",
        .playback = {
                .stream_name = "Playback",
                .channels_min = 1,
@@ -730,6 +776,8 @@ static struct snd_soc_dai_driver wm8988_dai = {
 
 static int wm8988_suspend(struct snd_soc_codec *codec, pm_message_t state)
 {
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
        wm8988_set_bias_level(codec, SND_SOC_BIAS_OFF);
        return 0;
 }
@@ -740,6 +788,8 @@ static int wm8988_resume(struct snd_soc_codec *codec)
        u8 data[2];
        u16 *cache = codec->reg_cache;
 
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
        /* Sync reg_cache with the hardware */
        for (i = 0; i < WM8988_NUM_REG; i++) {
                if (i == WM8988_RESET)
@@ -748,12 +798,30 @@ static int wm8988_resume(struct snd_soc_codec *codec)
                data[1] = cache[i] & 0x00ff;
                codec->hw_write(codec->control_data, data, 2);
        }
+       
+       //snd_soc_write(codec, WM8988_PWR1, 0xfc);
+       //snd_soc_write(codec, WM8988_PWR2, 0x1e0);
 
        wm8988_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
        return 0;
 }
 
+static struct snd_soc_codec *wm8988_codec;
+
+static int entry_read(char *page, char **start, off_t off,
+               int count, int *eof, void *data)
+{
+       int len;
+
+       snd_soc_write(wm8988_codec, WM8988_PWR1, 0x0000);
+       snd_soc_write(wm8988_codec, WM8988_PWR2, 0x0000);
+
+       len = sprintf(page, "wm8988 suspend...\n");
+
+       return len ;
+}
+
 static int wm8988_probe(struct snd_soc_codec *codec)
 {
        struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec);
@@ -761,6 +829,13 @@ static int wm8988_probe(struct snd_soc_codec *codec)
        int ret = 0;
        u16 reg;
 
+       if (codec == NULL) {
+               dev_err(codec->dev, "Codec device not registered\n");
+               return -ENODEV;
+       }
+
+       wm8988_codec = codec;
+
        ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8988->control_type);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
@@ -773,6 +848,14 @@ static int wm8988_probe(struct snd_soc_codec *codec)
                return ret;
        }
 
+#if 0
+               /*disable speaker */
+               gpio_request(RK2818_PIN_PF7, "WM8988"); 
+               rk2818_mux_api_set(GPIOE_SPI1_FLASH_SEL_NAME, IOMUXA_GPIO1_A3B7);
+               gpio_direction_output(RK2818_PIN_PF7,GPIO_HIGH);
+               
+#endif
+
        /* set the update bits (we always update left then right) */
        reg = snd_soc_read(codec, WM8988_RADC);
        snd_soc_write(codec, WM8988_RADC, reg | 0x100);
@@ -783,7 +866,40 @@ static int wm8988_probe(struct snd_soc_codec *codec)
        reg = snd_soc_read(codec, WM8988_ROUT2V);
        snd_soc_write(codec, WM8988_ROUT2V, reg | 0x0100);
        reg = snd_soc_read(codec, WM8988_RINVOL);
-       snd_soc_write(codec, WM8988_RINVOL, reg | 0x0100);
+       snd_soc_write(codec, WM8988_RINVOL, reg | 0x0100); 
+       
+       snd_soc_write(codec, WM8988_LOUTM1, 0x120); 
+       snd_soc_write(codec, WM8988_ROUTM2, 0x120);  
+       snd_soc_write(codec, WM8988_LOUTM2, 0x0070);
+       snd_soc_write(codec, WM8988_ROUTM1, 0x0070);
+//tcl miaozh modify    
+//     snd_soc_write(codec, WM8988_LOUT1V, 0x017f); 
+//     snd_soc_write(codec, WM8988_ROUT1V, 0x017f);
+       snd_soc_write(codec, WM8988_LOUT1V, 0x017a); 
+       snd_soc_write(codec, WM8988_ROUT1V, 0x017a);
+       
+       snd_soc_write(codec, WM8988_LDAC, 0xfa/*0xff*/);  // Change max by zhansb@110415
+       snd_soc_write(codec, WM8988_RDAC, 0x1fa/*0x1ff*/);//vol set 
+
+       //TCL lgw add 20110412
+       snd_soc_write(codec, WM8988_LINVOL,  0x0117);
+       snd_soc_write(codec, WM8988_RINVOL,  0x0117);
+
+       snd_soc_write(codec, WM8988_ADCTL2, 0x0184);
+
+       snd_soc_write(codec, WM8988_LADC, 0x01ec);
+       snd_soc_write(codec, WM8988_RADC, 0x01ec);
+       
+       snd_soc_write(codec, WM8988_ADCIN,  0x0140);
+       snd_soc_write(codec, WM8988_LADCIN, 0x00f0);//0x00e0
+       snd_soc_write(codec, WM8988_RADCIN, 0x0);//0x00e0
+       //lgw end
+       
+       snd_soc_write(codec, WM8988_SRATE,0x100);  ///SET MCLK/8
+       //snd_soc_write(codec, WM8988_PWR1, 0x1cc);  ///(0x80|0x40|0x20|0x08|0x04|0x10|0x02));
+       //TCL lgw modify 20110412
+       //snd_soc_write(codec, WM8988_PWR1, 0xfc);
+       //snd_soc_write(codec, WM8988_PWR2, 0x1e0);  //power r l out1
 
        wm8988_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
@@ -792,6 +908,7 @@ static int wm8988_probe(struct snd_soc_codec *codec)
        snd_soc_dapm_new_controls(dapm, wm8988_dapm_widgets,
                                  ARRAY_SIZE(wm8988_dapm_widgets));
        snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
+       create_proc_read_entry("wm8988_suspend", 0644, NULL, entry_read, NULL);
 
        return 0;
 }
@@ -842,7 +959,7 @@ static int __devexit wm8988_spi_remove(struct spi_device *spi)
 
 static struct spi_driver wm8988_spi_driver = {
        .driver = {
-               .name   = "wm8988-codec",
+               .name   = "WM8988",
                .owner  = THIS_MODULE,
        },
        .probe          = wm8988_spi_probe,
@@ -886,7 +1003,7 @@ MODULE_DEVICE_TABLE(i2c, wm8988_i2c_id);
 
 static struct i2c_driver wm8988_i2c_driver = {
        .driver = {
-               .name = "wm8988-codec",
+               .name = "WM8988",
                .owner = THIS_MODULE,
        },
        .probe =    wm8988_i2c_probe,
index 83014a7c2e142ccf0a63cafa3c38519b4f2fd5c8..8da1cc17b79cf46ee3fbb8edaaa982a73885f0fe 100755 (executable)
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
+#define DEBUG
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -3228,7 +3228,7 @@ static int __devexit wm8994_remove(struct platform_device *pdev)
 
 static struct platform_driver wm8994_codec_driver = {
        .driver = {
-                  .name = "wm8994-codec",
+                  .name = "WM8994",
                   .owner = THIS_MODULE,
                   },
        .probe = wm8994_probe,
index 433fb2ba9732465310f7f159a2fa044a0f3b90ad..9474a30ea572fac100511a68ad051a16cf54bacb 100755 (executable)
@@ -52,14 +52,14 @@ config SND_RK29_SOC_WM8900
        help
          Say Y if you want to add support for SoC audio on rockchip
          with the WM8900.
-config SND_RK29_SOC_alc5621
-       tristate "SoC I2S Audio support for rockchip - alc5621"
+config SND_RK29_SOC_RT5621
+       tristate "SoC I2S Audio support for rockchip - rt5621"
        depends on SND_RK29_SOC && I2C_RK29
        select SND_RK29_SOC_I2S
-       select SND_SOC_alc5621
+       select SND_SOC_RT5621
        help
          Say Y if you want to add support for SoC audio on rockchip
-         with the alc5621.
+         with the rt5621.
 config SND_RK29_SOC_RT5631
        tristate "SoC I2S Audio support for rockchip - RT5631"
        depends on SND_RK29_SOC && I2C_RK29
@@ -105,7 +105,7 @@ config SND_RK29_SOC_RK1000
          Say Y if you want to add support for SoC audio on rockchip
          with the RK1000.       
           
-if SND_RK29_SOC_WM8988 || SND_RK29_SOC_RK1000 || SND_RK29_SOC_WM8994 || SND_RK29_SOC_WM8900 || SND_RK29_SOC_alc5621 || SND_RK29_SOC_RT5631 || SND_RK29_SOC_RT5625 || SND_RK29_SOC_CS42L52
+if SND_RK29_SOC_WM8988 || SND_RK29_SOC_RK1000 || SND_RK29_SOC_WM8994 || SND_RK29_SOC_WM8900 || SND_RK29_SOC_RT5621 || SND_RK29_SOC_RT5631 || SND_RK29_SOC_RT5625 || SND_RK29_SOC_CS42L52
 choice
   prompt "Set i2s type"
        config SND_RK29_CODEC_SOC_MASTER
index 657cdab9133151bb8bffa5f48085abd988f8f47a..cc0c09b0b40d4a350612a80bca0794fc51d5ba54 100644 (file)
@@ -7,7 +7,7 @@ obj-$(CONFIG_SND_RK29_SOC_I2S) += snd-soc-rockchip-i2s.o
 
 # ROCKCHIP Machine Support
 snd-soc-wm8900-objs := rk29_wm8900.o
-snd-soc-alc5621-objs := rk29_alc5621.o
+snd-soc-rt5621-objs := rk29_rt5621.o
 snd-soc-rt5631-objs := rk29_rt5631.o
 snd-soc-rt5625-objs := rk29_rt5625.o
 snd-soc-cs42l52-objs := rk29_cs42l52.o
@@ -18,7 +18,7 @@ snd-soc-wm8994-objs := rk29_wm8994.o
 obj-$(CONFIG_SND_RK29_SOC_WM8994) += snd-soc-wm8994.o
 obj-$(CONFIG_SND_RK29_SOC_WM8988) += snd-soc-wm8988.o
 obj-$(CONFIG_SND_RK29_SOC_WM8900) += snd-soc-wm8900.o
-obj-$(CONFIG_SND_RK29_SOC_alc5621) += snd-soc-alc5621.o
+obj-$(CONFIG_SND_RK29_SOC_RT5621) += snd-soc-rt5621.o
 obj-$(CONFIG_SND_RK29_SOC_RT5631) += snd-soc-rt5631.o
 obj-$(CONFIG_SND_RK29_SOC_RT5625) += snd-soc-rt5625.o
 obj-$(CONFIG_SND_RK29_SOC_RK1000) += snd-soc-rk1000.o
diff --git a/sound/soc/rk29/rk29_alc5621.c b/sound/soc/rk29/rk29_alc5621.c
deleted file mode 100644 (file)
index 62f2ed5..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * rk29_wm8900.c  --  SoC audio for rockchip
- *
- * Driver for rockchip alc5623 audio
- *
- *  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.
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/device.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/soc.h>
-#include <sound/soc-dapm.h>
-#include <asm/io.h>
-#include <mach/hardware.h>
-#include <mach/rk29_iomap.h>
-#include "../codecs/alc5621.h"
-#include "rk29_pcm.h"
-#include "rk29_i2s.h"
-
-#if 1
-#define        DBG(x...)       printk(KERN_INFO x)
-#else
-#define        DBG(x...)
-#endif
-
-
-
-static int rk29_hw_params_alc5623(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
-{
-        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-        struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
-        struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
-        unsigned int pll_out = 0i,sys_clk; 
-        int ret;
-          
-        DBG("rk29_hw_params for rk29_alc5623\n");    
-        /*by Vincent Hsiung for EQ Vol Change*/
-        #define HW_PARAMS_FLAG_EQVOL_ON 0x21
-        #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
-        if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
-        {
-               ret = codec_dai->ops->hw_params(substream, params, codec_dai); //by Vincent
-               DBG("rk29_hw_params set EQ vol for rk29_alc5623\n");
-        }
-        else
-        {
-                
-            /* set codec DAI configuration for codec side */
-            #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
-                DBG("rk29_hw_params for rk29_alc5623  codec as slave\n");    
-                ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
-            #endif     
-
-                   #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
-                ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); 
-            #endif
-                if (ret < 0)return ret; 
-
-            /* set cpu DAI configuration */
-            #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
-                DBG("rk29_hw_params for rk29_alc5623  cpu as master\n");    
-                ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-            #endif     
-
-                       #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
-                ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);        
-             #endif            
-                if (ret < 0)return ret;
-
-        }
-
-
-        switch(params_rate(params)) {
-        case 8000:
-              sys_clk=  12288000;
-              pll_out = 12288000;
-             break; 
-        case 16000:
-             sys_clk=  11289600;
-             pll_out = 12288000;
-             break;
-        case 24000:
-             sys_clk = 24576000;
-             pll_out = 12288000;
-             break;
-        case 32000:
-             sys_clk=  12288000;
-             pll_out = 12288000;
-        case 48000:
-             sys_clk =  12288000;
-              pll_out = 12288000;
-                break;
-        /*------------------------------*/
-        case 11025:
-             sys_clk = 11289600; 
-             pll_out = 11289600;
-             break;
-        case 22050:
-             sys_clk = 11289600;
-             pll_out = 11289600;
-             break;
-
-        case 44100:
-             sys_clk = 11289600;
-             pll_out = 11289600;
-             break;
-        default:
-                DBG("rk29_hw_params for rk29_alc5623,invalid sapmleRate:%d\n",params_rate(params));
-                return -EINVAL;
-                break;
-        }
-        DBG("rk29_hw_params for rk29_alc5623, sapmleRate:%d\n",params_rate(params));
-
-                   
-          /*Set the system clk for codec*/
-           ret=snd_soc_dai_set_sysclk(codec_dai, 0,sys_clk,SND_SOC_CLOCK_IN);//ALC5621 system clk from MCLK or PLL
-           if (ret < 0)
-           {
-              DBG("rk29_hw_params_alc5623:failed to set the sysclk for codec side\n"); 
-                  return ret;
-               }
-
-            /*Set the pll of alc5621,the Pll source from MCLK no matter slave or master mode*/
-           ret=snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_BCLK,params_rate(params)*64,sys_clk);
-           if (ret < 0)
-           { 
-              DBG("rk29_hw_params_alc5623:failed to set the pll for codec side\n"); 
-                  return ret;
-           }
-        
-
-        #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
-        snd_soc_dai_set_clkdiv(codec_dai, ALC5623_BCLK_DIV, ALC5623_BCLK_DIV_4);        
-       snd_soc_dai_set_clkdiv(codec_dai, ALC5623_DAC_LRCLK,(pll_out/4)/params_rate(params));
-        snd_soc_dai_set_clkdiv(codec_dai, ALC5623_ADC_LRCLK,(pll_out/4)/params_rate(params));
-        #endif
-
-        #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
-        snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
-        snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
-        snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
-        #endif
-        DBG("rk29_hw_params_alc5623:,LRCK=%d\n",(pll_out/4)/params_rate(params));        
-        return 0;
-}
-
-static const struct snd_soc_dapm_widget alc5623_dapm_widgets[] = {
-       SND_SOC_DAPM_LINE("Audio Out", NULL),
-       SND_SOC_DAPM_LINE("Line in", NULL),
-       SND_SOC_DAPM_MIC("Micn", NULL),
-       SND_SOC_DAPM_MIC("Micp", NULL),
-};
-
-static const struct snd_soc_dapm_route audio_map[]= {
-       
-       {"Audio Out", NULL, "HP_L"},
-       {"Audio Out", NULL, "HP_R"},
-       {"Line in", NULL, "RINPUT1"},
-       {"Line in", NULL, "LINPUT1"},
-       {"Micn", NULL, "RINPUT2"},
-       {"Micp", NULL, "LINPUT2"},
-};
-
-/*
- * Logic for a wm8900 as connected on a rockchip board.
- */
-static int rk29_alc5623_init(struct snd_soc_codec *codec)
-{
-         
-    DBG("rk29_alc5623_init\n");
-
-    /* Add specific widgets */
-       snd_soc_dapm_new_controls(codec, alc5623_dapm_widgets, ARRAY_SIZE(alc5623_dapm_widgets));
-               
-    /* Set up specific audio path audio_mapnects */
-    snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
-    snd_soc_dapm_nc_pin(codec, "HP_L");
-    snd_soc_dapm_nc_pin(codec, "HP_R");
-       snd_soc_dapm_sync(codec);
-    DBG("rk29_alc5623_init   end\n");
-    return 0;
-}
-
-static struct snd_soc_ops rk29_ops = {
-       .hw_params = rk29_hw_params_alc5623,
-};
-
-static struct snd_soc_dai_link rk29_dai_alc5623 = {
-       .name = "ALC5623",
-       .stream_name = "ALC5623 PCM",
-       .cpu_dai = &rk29_i2s_dai[0],
-       .codec_dai = &rt5621_dai,
-       .init = rk29_alc5623_init,
-       .ops = &rk29_ops,
-};
-
-static struct snd_soc_card snd_soc_card_rk29_alc5623 = {
-         .name = "RK29_ALC5623",
-         .platform = &rk29_soc_platform,
-         .dai_link = &rk29_dai_alc5623,
-         .num_links = 1,
-};
-
-
-static struct snd_soc_device rk29_snd_devdata_alc5623 = {
-         .card = &snd_soc_card_rk29_alc5623,
-         .codec_dev = &soc_codec_dev_rt5621,
-};
-
-static struct platform_device *rk29_snd_device_alc5623;
-
-static int __init audio_card_init_alc5623(void)
-{
-       int ret =0;     
-        DBG("audio_card_init_alc5623\n");
-       rk29_snd_device_alc5623 = platform_device_alloc("soc-audio", -1);
-       if (!rk29_snd_device_alc5623) {
-           DBG("audio_card_init_alc5623:platform device allocation failed\n");
-          ret = -ENOMEM;
-          return ret;
-       }
-       platform_set_drvdata(rk29_snd_device_alc5623, &rk29_snd_devdata_alc5623);
-       rk29_snd_devdata_alc5623.dev = &rk29_snd_device_alc5623->dev;
-       ret = platform_device_add(rk29_snd_device_alc5623);
-       if (ret) {
-               DBG("audio_card_init_alc5623:platform device add failed\n");
-               platform_device_put(rk29_snd_device_alc5623);
-       }
-       return ret;
-}
-
-static void __exit audio_card_exit_alc5623(void)
-{
-       platform_device_unregister(rk29_snd_device_alc5623);
-}
-
-module_init(audio_card_init_alc5623);
-module_exit(audio_card_exit_alc5623);
-/* Module information */
-MODULE_AUTHOR("rockchip");
-MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
-MODULE_LICENSE("GPL");
index 689a9910f71e5f4009b9203b0cfe998570129864..a2cb3e96a8dc399daa563b92e9b225698054c1df 100755 (executable)
@@ -413,10 +413,14 @@ static int rockchip_pcm_close(struct snd_pcm_substream *substream)
         struct rockchip_dma_buf_set *sg_buf = NULL;
        DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
 
-       if (!prtd)
+       if (!prtd) {
                DBG("rockchip_pcm_close called with prtd == NULL\n");
-        if (prtd) 
-               sg_buf = prtd->curr;
+               return 0;
+       }
+
+       if (prtd->params)
+               rk29_dma_set_buffdone_fn(prtd->params->channel, NULL);
+       sg_buf = prtd->curr;
 
        while (sg_buf != NULL) {
                prtd->curr = sg_buf->next;
diff --git a/sound/soc/rk29/rk29_rt5621.c b/sound/soc/rk29/rk29_rt5621.c
new file mode 100644 (file)
index 0000000..dca3e84
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+ * rk29_rt5621.c  --  SoC audio for rockchip
+ *
+ * Driver for rockchip rt5621 audio
+ *
+ *  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.
+ *
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <asm/io.h>
+#include <mach/hardware.h>
+#include <mach/rk29_iomap.h>
+#include "../codecs/rt5621.h"
+#include "rk29_pcm.h"
+#include "rk29_i2s.h"
+
+#if 0
+#define        DBG(x...)       printk(KERN_INFO x)
+#else
+#define        DBG(x...)
+#endif
+
+static int rk29_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       unsigned int pll_out = 0; 
+       unsigned int lrclk = 0;
+       int ret;
+         
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    
+
+       /*by Vincent Hsiung for EQ Vol Change*/
+       #define HW_PARAMS_FLAG_EQVOL_ON 0x21
+       #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
+       if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
+       {
+               ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
+               DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+       } else {
+               /* set codec DAI configuration */
+#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
+               ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+                       SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
+#endif
+#if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
+               ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+                       SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); 
+#endif
+               if (ret < 0)
+                       return ret; 
+               /* set cpu DAI configuration */
+#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
+               ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+                       SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+#endif
+#if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
+               ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+                       SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
+#endif
+               if (ret < 0)
+                       return ret;
+       }
+
+       switch(params_rate(params)) {
+       case 8000:
+       case 16000:
+       case 24000:
+       case 32000:
+       case 48000:
+               pll_out = 12288000;
+               break;
+       case 11025:
+       case 22050:
+       case 44100:
+               pll_out = 11289600;
+               break;
+       default:
+               DBG("Enter:%s, %d, Error rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+               return -EINVAL;
+               break;
+       }
+       DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+
+#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
+#if 0  //use pll from blck
+       /*Set the pll of rt5621,the Pll source from BITCLK on CPU is master mode*/
+       //bitclk is 64fs           
+       ret=snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_BCLK,params_rate(params)*64,pll_out);
+       if (ret < 0) { 
+               DBG("rk29_hw_params_rt5621:failed to set the pll for codec side\n"); 
+               return ret;
+       }
+#endif     
+       /*Set the system clk for codec*/
+       ret=snd_soc_dai_set_sysclk(codec_dai, 0,pll_out,SND_SOC_CLOCK_IN);
+       if (ret < 0) {
+               DBG("rk29_hw_params_rt5621:failed to set the sysclk for codec side\n"); 
+               return ret;
+       }           
+#endif
+  
+
+  #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
+
+       if((24576000%params_rate(params))==0)   //for 8k,16k,32k,48k
+       {
+               snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_MCLK,pll_out, 24576000);
+               snd_soc_dai_set_sysclk(codec_dai,0, 24576000, SND_SOC_CLOCK_IN);                        
+       }
+       else if((22579200%params_rate(params))==0)      //for 11k,22k,44k
+       {
+               snd_soc_dai_set_pll(codec_dai,RT5621_PLL_FR_MCLK,pll_out, 22579200);
+               snd_soc_dai_set_sysclk(codec_dai,0, 22579200, SND_SOC_CLOCK_IN);                        
+       }
+      
+#endif
+
+
+#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
+       snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+       snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK, (pll_out/4)/params_rate(params)-1);
+       snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, 3);
+#endif
+
+       DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));
+        
+       return 0;
+}
+
+static const struct snd_soc_dapm_widget rt5621_dapm_widgets[] = {
+       
+       SND_SOC_DAPM_MIC("Mic Jack", NULL),
+       SND_SOC_DAPM_SPK("Ext Spk", NULL),
+       SND_SOC_DAPM_HP("Headphone Jack", NULL),
+
+};
+
+static const struct snd_soc_dapm_route audio_map[]={
+
+       /* Mic Jack --> MIC_IN*/
+       {"Mic Bias1", NULL, "Mic Jack"},
+       {"MIC1", NULL, "Mic Bias1"},
+       /* HP_OUT --> Headphone Jack */
+       {"Headphone Jack", NULL, "HPOL"},
+       {"Headphone Jack", NULL, "HPOR"},
+       /* LINE_OUT --> Ext Speaker */
+       {"Ext Spk", NULL, "SPOL"},
+       {"Ext Spk", NULL, "SPOR"},
+
+} ;
+
+/*
+ * Logic for a rt5621 as connected on a rockchip board.
+ */
+static int rk29_rt5621_init(struct snd_soc_pcm_runtime *rtd)
+{
+        return 0;
+}
+
+static struct snd_soc_ops rk29_ops = {
+         .hw_params = rk29_hw_params,
+};
+
+static struct snd_soc_dai_link rk29_dai = {
+       .name = "RT5621",
+       .stream_name = "RT5621 PCM",
+       .codec_name = "RT5621.0-001a",
+       .platform_name = "rockchip-audio",
+       .cpu_dai_name = "rk29_i2s.0",
+       .codec_dai_name = "RT5621 HiFi",
+       .init = rk29_rt5621_init,
+       .ops = &rk29_ops,
+};
+
+static struct snd_soc_card snd_soc_card_rk29 = {
+       .name = "RK29_RT5621",
+       .dai_link = &rk29_dai,
+       .num_links = 1,
+};
+
+static struct platform_device *rk29_snd_device;
+
+static int __init audio_card_init(void)
+{
+       int ret =0;     
+       
+       //rk29_speaker = rk29_speaker_init(RK29_PIN6_PB6, GPIO_HIGH, 2, (200*1000*1000));
+
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+       rk29_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!rk29_snd_device) {
+                 DBG("platform device allocation failed\n");
+                 ret = -ENOMEM;
+                 return ret;
+       }
+       platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29);
+       ret = platform_device_add(rk29_snd_device);
+       if (ret) {
+           DBG("platform device add failed\n");
+           platform_device_put(rk29_snd_device);
+               return ret;
+       }
+       return ret;
+}
+
+static void __exit audio_card_exit(void)
+{
+       platform_device_unregister(rk29_snd_device);
+}
+
+module_init(audio_card_init);
+module_exit(audio_card_exit);
+/* Module information */
+MODULE_AUTHOR("rockchip");
+MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
+MODULE_LICENSE("GPL");
index 29c4a709ab84a91cfdf7feab8c9b35d4443cb0f3..e9abd89e43b5e44f5d689d02cd4017c76f635308 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * rk2818_wm8988.c  --  SoC audio for rockchip
+ * rk29_wm8988.c  --  SoC audio for rockchip
  *
  * Driver for rockchip wm8988 audio
  *
 #include "rk29_pcm.h"
 #include "rk29_i2s.h"
 
+#include <mach/gpio.h>
+
 #if 0
 #define        DBG(x...)       printk(KERN_INFO x)
 #else
 #define        DBG(x...)
 #endif
 
-static int rk2818_hw_params(struct snd_pcm_substream *substream,
+//static void *rk29_speaker = NULL;
+
+static int rk29_hw_params(struct snd_pcm_substream *substream,
        struct snd_pcm_hw_params *params)
 {
-    struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
-       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        int ret;
          
     DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    
@@ -44,39 +48,39 @@ static int rk2818_hw_params(struct snd_pcm_substream *substream,
        #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
     if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
     {
-       ret = codec_dai->ops->hw_params(substream, params, codec_dai); //by Vincent
+               ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
        DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
     }
     else
     {
            /* set codec DAI configuration */
-           #if defined (CONFIG_SND_CODEC_SOC_SLAVE) 
-           ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+           #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
+                ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
            #endif      
-           #if defined (CONFIG_SND_CODEC_SOC_MASTER) 
-           ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+           #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
+                ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); 
            #endif
            if (ret < 0)
                  return ret; 
            /* set cpu DAI configuration */
-           #if defined (CONFIG_SND_CODEC_SOC_SLAVE) 
-           ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+           #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
+                ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
            #endif      
-           #if defined (CONFIG_SND_CODEC_SOC_MASTER) 
-           ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+           #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER) 
+                ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
            #endif              
            if (ret < 0)
                  return ret;
          }
-    
+       
          return 0;
 }
 
-static const struct snd_soc_dapm_widget rk2818_dapm_widgets[] = {
+static const struct snd_soc_dapm_widget rk29_dapm_widgets[] = {
        SND_SOC_DAPM_LINE("Audio Out", NULL),
        SND_SOC_DAPM_LINE("Line in", NULL),
        SND_SOC_DAPM_MIC("Micn", NULL),
@@ -96,84 +100,86 @@ static const struct snd_soc_dapm_route audio_map[]= {
 /*
  * Logic for a wm8988 as connected on a rockchip board.
  */
-static int rk2818_wm8988_init(struct snd_soc_codec *codec)
+static int rk29_wm8988_init(struct snd_soc_pcm_runtime *rtd)
 {
-       struct snd_soc_dai *codec_dai = &codec->dai[0];
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_dapm_context *dapm = &codec->dapm;
        int ret;
          
     DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
     
     ret = snd_soc_dai_set_sysclk(codec_dai, 0,
-               12000000, SND_SOC_CLOCK_IN);
+               /*12000000*/11289600, SND_SOC_CLOCK_IN);
        if (ret < 0) {
                printk(KERN_ERR "Failed to set WM8988 SYSCLK: %d\n", ret);
                return ret;
        }
        
     /* Add specific widgets */
-       snd_soc_dapm_new_controls(codec, rk2818_dapm_widgets,
-                                 ARRAY_SIZE(rk2818_dapm_widgets));
-       snd_soc_dapm_nc_pin(codec, "LOUT2");
-       snd_soc_dapm_nc_pin(codec, "ROUT2");
+       snd_soc_dapm_new_controls(dapm, rk29_dapm_widgets,
+                                 ARRAY_SIZE(rk29_dapm_widgets));
+       //snd_soc_dapm_nc_pin(codec, "LOUT2");
+       //snd_soc_dapm_nc_pin(codec, "ROUT2");
        
     /* Set up specific audio path audio_mapnects */
-    snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
+        snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
        
-    snd_soc_dapm_sync(codec);
+        snd_soc_dapm_sync(dapm);
  
     return 0;
 }
 
-static struct snd_soc_ops rk2818_ops = {
-         .hw_params = rk2818_hw_params,
+static struct snd_soc_ops rk29_ops = {
+         .hw_params = rk29_hw_params,
 };
 
-static struct snd_soc_dai_link rk2818_dai = {
-         .name = "WM8988",
-         .stream_name = "WM8988 PCM",
-         .cpu_dai = &rk2818_i2s_dai,
-         .codec_dai = &wm8988_dai,
-         .init = rk2818_wm8988_init,
-         .ops = &rk2818_ops,
+static struct snd_soc_dai_link rk29_dai = {
+       .name = "WM8988",
+       .stream_name = "WM8988 PCM",
+       .codec_name = "WM8988.0-001a",
+       .platform_name = "rockchip-audio",
+       .cpu_dai_name = "rk29_i2s.0",
+       .codec_dai_name = "WM8988 HiFi",
+       .init = rk29_wm8988_init,
+       .ops = &rk29_ops,
 };
 
-static struct snd_soc_card snd_soc_card_rk2818 = {
-         .name = "RK2818_WM8988",
-         .platform = &rk2818_soc_platform,
-         .dai_link = &rk2818_dai,
-         .num_links = 1,
+static struct snd_soc_card snd_soc_card_rk29 = {
+       .name = "RK29_WM8988",
+       .dai_link = &rk29_dai,
+       .num_links = 1,
 };
 
-
-static struct snd_soc_device rk2818_snd_devdata = {
-         .card = &snd_soc_card_rk2818,
-         .codec_dev = &soc_codec_dev_wm8988,
-};
-
-static struct platform_device *rk2818_snd_device;
+static struct platform_device *rk29_snd_device;
 
 static int __init audio_card_init(void)
 {
-       int ret =0;     
+    int ret =0;        
+       
+    //rk29_speaker = rk29_speaker_init(RK29_PIN6_PB6, GPIO_HIGH, 2, (200*1000*1000));
+
     DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
-       rk2818_snd_device = platform_device_alloc("soc-audio", -1);
-       if (!rk2818_snd_device) {
+       rk29_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!rk29_snd_device) {
                  DBG("platform device allocation failed\n");
                  ret = -ENOMEM;
                  return ret;
        }
-       platform_set_drvdata(rk2818_snd_device, &rk2818_snd_devdata);
-       rk2818_snd_devdata.dev = &rk2818_snd_device->dev;
-       ret = platform_device_add(rk2818_snd_device);
+       platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29);
+       ret = platform_device_add(rk29_snd_device);
        if (ret) {
            DBG("platform device add failed\n");
-           platform_device_put(rk2818_snd_device);
+           platform_device_put(rk29_snd_device);
+            return ret;
        }
-       return ret;
+               
+        return ret;
 }
 static void __exit audio_card_exit(void)
 {
-       platform_device_unregister(rk2818_snd_device);
+    platform_device_unregister(rk29_snd_device);
+    //rk29_speaker_deinit(rk29_speaker);       
 }
 
 module_init(audio_card_init);
index b666b0c2090645f23e7eec5348a69f0213dd1241..84222e918eefbfe120bf8876bd85b896a8e09bc6 100755 (executable)
 #include "rk29_i2s.h"
 #include <linux/clk.h>
 
-#if 0
+#if 1
 #define        DBG(x...)       printk(KERN_INFO x)
 #else
 #define        DBG(x...)
 #endif
 
-static int rk29_hw_params(struct snd_pcm_substream *substream,
+#define HW_PARAMS_FLAG_EQVOL_ON 0x21
+#define HW_PARAMS_FLAG_EQVOL_OFF 0x22
+
+static int rk29_aif1_hw_params(struct snd_pcm_substream *substream,
        struct snd_pcm_hw_params *params)
 {
-    struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
-       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;    
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        unsigned int pll_out = 0; 
        int div_bclk,div_mclk;
        int ret;
        struct clk      *general_pll;
-         
-    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    
+
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
+       if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
+       {
+               DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
+               if (codec_dai->driver->ops->hw_params)
+                       ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); //by Vincent
+
+               return 0;
+       }
+
        /* set codec DAI configuration */
 #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
-       DBG("Set codec_dai slave\n");    
+       DBG("Set codec_dai slave\n");
        ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-                           SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
 #endif 
 #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)                            
-    ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
-                           SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
-       DBG("Set codec_dai master\n");                                          
+       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+       DBG("Set codec_dai master\n");
 #endif
-    if (ret < 0)
-        return ret; 
+       if (ret < 0)
+               return ret; 
 
        /* set cpu DAI configuration */
 #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
-       DBG("Set cpu_dai slave\n");    
+       DBG("Set cpu_dai slave\n");
        ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-                            SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
 #endif 
 #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)  
        ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
-                            SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);    
-       DBG("Set cpu_dai master\n");                            
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
+       DBG("Set cpu_dai master\n"); 
 #endif         
        if (ret < 0)
                return ret;
 
-    switch(params_rate(params)) {
-        case 8000:
-        case 16000:
-        case 24000:
-        case 32000:
-        case 48000:
-            pll_out = 12288000;
-            break;
-        case 11025:
-        case 22050:
-        case 44100:
-            pll_out = 11289600;
-            break;
-        default:
-            DBG("Enter:%s, %d, Error rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
-            return -EINVAL;
-            break;
-     }
-     DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+       switch(params_rate(params)) {
+               case 8000:
+               case 16000:
+               case 24000:
+               case 32000:
+               case 48000:
+                       pll_out = 12288000;
+                       break;
+               case 11025:
+               case 22050:
+               case 44100:
+                       pll_out = 11289600;
+                       break;
+               default:
+                       DBG("Enter:%s, %d, Error rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+                       return -EINVAL;
+                       break;
+       }
+
+       DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+
 #if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)         
        snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
-#endif 
-       
+#endif
+
 #if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
        general_pll=clk_get(NULL, "general_pll");
-       if(clk_get_rate(general_pll)>260000000)
-       {
+
+       if(clk_get_rate(general_pll)>260000000) {
                div_bclk=(pll_out/4)/params_rate(params)-1;
                div_mclk=3;
        }
@@ -113,21 +129,174 @@ static int rk29_hw_params(struct snd_pcm_substream *substream,
                div_bclk=(pll_out)/params_rate(params)-1;
                div_mclk=0;
        }
-       DBG("func is%s,gpll=%ld,pll_out=%ld,div_mclk=%ld\n",
-                       __FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk);
+       DBG("func is%s,gpll=%ld,pll_out=%d,div_mclk=%d\n",
+               __FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk);
        snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
        snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_BCLK,div_bclk);
        snd_soc_dai_set_clkdiv(cpu_dai, ROCKCHIP_DIV_MCLK, div_mclk);
        
+       if(div_mclk == 3)
+               snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
+       else
+               snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0);      
+#endif
+
+       return 0;
+}
+
+static int rk29_aif2_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       unsigned int pll_out = 0; 
+       int div_bclk,div_mclk;
+       int ret;
+       struct clk      *general_pll;
+
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
+       /* set codec DAI configuration */
+#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE) 
+       DBG("Set codec_dai slave\n");
+       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+#endif 
+#if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)                            
+       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+       DBG("Set codec_dai master\n");
+#endif
+       if (ret < 0)
+               return ret; 
+
+       switch(params_rate(params)) {
+               case 8000:
+               case 16000:
+               case 24000:
+               case 32000:
+               case 48000:
+                       pll_out = 12288000;
+                       break;
+               case 11025:
+               case 22050:
+               case 44100:
+                       pll_out = 11289600;
+                       break;
+               default:
+                       DBG("Enter:%s, %d, Error rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+                       return -EINVAL;
+                       break;
+       }
+
+       DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+
+#if defined (CONFIG_SND_RK29_CODEC_SOC_MASTER)         
+       snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+#endif
+
+#if defined (CONFIG_SND_RK29_CODEC_SOC_SLAVE)
+       general_pll=clk_get(NULL, "general_pll");
+
+       if(clk_get_rate(general_pll)>260000000) {
+               div_bclk=(pll_out/4)/params_rate(params)-1;
+               div_mclk=3;
+       }
+       else if(clk_get_rate(general_pll)>130000000)
+       {
+               div_bclk=(pll_out/2)/params_rate(params)-1;
+               div_mclk=1;
+       }
+       else
+       {
+               pll_out=pll_out/4;
+               div_bclk=(pll_out)/params_rate(params)-1;
+               div_mclk=0;
+       }
+       DBG("func is%s,gpll=%ld,pll_out=%d,div_mclk=%d\n",
+               __FUNCTION__,clk_get_rate(general_pll),pll_out,div_mclk);
+       snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+       
        if(div_mclk == 3)
                snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
        else
                snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0);
-       DBG("Enter:%s, %d, LRCK=%d\n",__FUNCTION__,__LINE__,(pll_out/4)/params_rate(params));           
 #endif
 
-    return 0;
+       return 0;
+}
+
+static int rk29_aif3_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+       unsigned int pll_out = 0; 
+       int div_bclk,div_mclk;
+       int ret;
+       struct clk      *general_pll;
+
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
+       /* set codec DAI configuration */                          
+       ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+       DBG("Set codec_dai master\n");
+
+       if (ret < 0)
+               return ret; 
+
+       switch(params_rate(params)) {
+               case 8000:
+               case 16000:
+               case 24000:
+               case 32000:
+               case 48000:
+                       pll_out = 12288000;
+                       break;
+               case 11025:
+               case 22050:
+               case 44100:
+                       pll_out = 11289600;
+                       break;
+               default:
+                       DBG("Enter:%s, %d, Error rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+                       return -EINVAL;
+                       break;
+       }
+
+       DBG("Enter:%s, %d, rate=%d\n",__FUNCTION__,__LINE__,params_rate(params));
+
+       snd_soc_dai_set_sysclk(cpu_dai, 0, pll_out, 0);
+
+       general_pll=clk_get(NULL, "general_pll");
+
+       if(clk_get_rate(general_pll)>260000000) {
+               div_bclk=(pll_out/4)/params_rate(params)-1;
+               div_mclk=3;
+       }
+       else if(clk_get_rate(general_pll)>130000000)
+       {
+               div_bclk=(pll_out/2)/params_rate(params)-1;
+               div_mclk=1;
+       }
+       else
+       {
+               pll_out=pll_out/4;
+               div_bclk=(pll_out)/params_rate(params)-1;
+               div_mclk=0;
+       }
+       
+       if(div_mclk == 3)
+               snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, pll_out, 0);
+       else
+               snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0);
+
+       return 0;
 }
+
 /*
 static const struct snd_soc_dapm_widget rk2818_dapm_widgets[] = {
        SND_SOC_DAPM_LINE("Audio Out", NULL),
@@ -149,80 +318,108 @@ static const struct snd_soc_dapm_route audio_map[]= {
 /*
  * Logic for a wm8994 as connected on a rockchip board.
  */
-static int rk29_wm8994_init(struct snd_soc_codec *codec)
+static int rk29_wm8994_init(struct snd_soc_pcm_runtime *rtd)
 {
-       struct snd_soc_dai *codec_dai = &codec->dai[0];
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct snd_soc_codec *codec = rtd->codec;
+       struct snd_soc_dapm_context *dapm = &codec->dapm;
        int ret;
 
-    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
     
-    ret = snd_soc_dai_set_sysclk(codec_dai, 0,
+       ret = snd_soc_dai_set_sysclk(codec_dai, 0,
                12000000, SND_SOC_CLOCK_IN);
        if (ret < 0) {
                printk(KERN_ERR "Failed to set WM8994 SYSCLK: %d\n", ret);
                return ret;
        }
        
-    /* Add specific widgets */
-//     snd_soc_dapm_new_controls(codec, rk2818_dapm_widgets,
-//                               ARRAY_SIZE(rk2818_dapm_widgets));     
-    /* Set up specific audio path audio_mapnects */
-//    snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));       
-//    snd_soc_dapm_sync(codec);
+       /* Add specific widgets */
+//     snd_soc_dapm_new_controls(dapm, rk2818_dapm_widgets,
+//             ARRAY_SIZE(rk2818_dapm_widgets));       
+       /* Set up specific audio path audio_mapnects */
+//     snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));       
+//     snd_soc_dapm_sync(codec);
  
     return 0;
 }
 
-static struct snd_soc_ops rk29_ops = {
-         .hw_params = rk29_hw_params,
+static struct snd_soc_ops rk29_aif1_ops = {
+         .hw_params = rk29_aif1_hw_params,
 };
 
-static struct snd_soc_dai_link rk29_dai = {
-         .name = "WM8994",
-         .stream_name = "WM8994 PCM",
-#ifdef CONFIG_MACH_RK29_PHONEPADSDK
-         .cpu_dai = &rk29_i2s_dai[1],
-#else
-          .cpu_dai = &rk29_i2s_dai[0],
-#endif
-         .codec_dai = &wm8994_dai,
-         .init = rk29_wm8994_init,
-         .ops = &rk29_ops,
+static struct snd_soc_ops rk29_aif2_ops = {
+         .hw_params = rk29_aif2_hw_params,
 };
 
-static struct snd_soc_card snd_soc_card_rk29 = {
-         .name = "RK29_WM8994",
-         .platform = &rk29_soc_platform,
-         .dai_link = &rk29_dai,
-         .num_links = 1,
+static struct snd_soc_ops rk29_aif3_ops = {
+         .hw_params = rk29_aif3_hw_params,
 };
 
+static struct snd_soc_dai_link rk29_dai[] = {
+       {
+               .name = "WM8994",
+               .stream_name = "WM8994 I2S1",
+               .codec_name = "WM8994.0-001a",
+               .platform_name = "rockchip-audio",
+               .cpu_dai_name = "rk29_i2s.0",
+               .codec_dai_name = "wm8994-aif1",
+               .init = rk29_wm8994_init,
+               .ops = &rk29_aif1_ops,
+       },
+       {
+               .name = "WM8994",
+               .stream_name = "WM8994 I2S2",
+               .codec_name = "WM8994.1-001a",
+               .platform_name = "rockchip-audio",
+               .cpu_dai_name = "rk29_i2s.0",
+               .codec_dai_name = "wm8994-aif2",
+               .init = rk29_wm8994_init,
+               .ops = &rk29_aif2_ops,
+       },
+       {
+               .name = "WM8994",
+               .stream_name = "WM8994 I2S3",
+               .codec_name = "WM8994.2-001a",
+               .platform_name = "rockchip-audio",
+               .cpu_dai_name = "rk29_i2s.0",
+               .codec_dai_name = "wm8994-aif3",
+               .init = rk29_wm8994_init,
+               .ops = &rk29_aif3_ops,
+       },
+};
 
-static struct snd_soc_device rk29_snd_devdata = {
-         .card = &snd_soc_card_rk29,
-         .codec_dev = &soc_codec_dev_wm8994,
+static struct snd_soc_card snd_soc_card_rk29 = {
+       .name = "RK29_WM8994",
+       .dai_link = rk29_dai,
+       .num_links = 3,
 };
 
 static struct platform_device *rk29_snd_device;
 
 static int __init audio_card_init(void)
 {
-       int ret =0;     
-        DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+       int ret =0;
+
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+
        rk29_snd_device = platform_device_alloc("soc-audio", -1);
        if (!rk29_snd_device) {
                  DBG("platform device allocation failed\n");
                  ret = -ENOMEM;
                  return ret;
        }
-       platform_set_drvdata(rk29_snd_device, &rk29_snd_devdata);
-       rk29_snd_devdata.dev = &rk29_snd_device->dev;
+
+       platform_set_drvdata(rk29_snd_device, &snd_soc_card_rk29);
        ret = platform_device_add(rk29_snd_device);
        if (ret) {
-               DBG("platform device add failed\n");
-               platform_device_put(rk29_snd_device);
+               DBG("platform device add failed\n");
+
+               platform_device_put(rk29_snd_device);
+               return ret;
        }
-       return ret;
+               
+        return ret;
 }
 
 static void __exit audio_card_exit(void)