diff --git a/arch/arm/configs/rk29_ddr3sdk_defconfig b/arch/arm/configs/rk29_ddr3sdk_defconfig index ebe4cb2139f4..15763db14f9f 100755 --- a/arch/arm/configs/rk29_ddr3sdk_defconfig +++ b/arch/arm/configs/rk29_ddr3sdk_defconfig @@ -1,491 +1,79 @@ -# -# 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 diff --git a/arch/arm/configs/rk29_k97_defconfig b/arch/arm/configs/rk29_k97_defconfig new file mode 100644 index 000000000000..3253901ed3ae --- /dev/null +++ b/arch/arm/configs/rk29_k97_defconfig @@ -0,0 +1,2653 @@ +# +# Automatically generated make config: don't edit +# Linux/arm 3.0.8 Kernel Configuration +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_HAVE_SCHED_CLOCK=y +CONFIG_GENERIC_GPIO=y +# CONFIG_ARCH_USES_GETTIMEOFFSET is not set +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_KTIME_SCALAR=y +CONFIG_HAVE_PROC_CPU=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_ARCH_HAS_CPU_IDLE_WAIT=y +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_ZONE_DMA=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_VECTORS_BASE=0xffff0000 +# CONFIG_ARM_PATCH_PHYS_VIRT is not set +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +CONFIG_HAVE_IRQ_WORK=y + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_CROSS_COMPILE="" +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_HAVE_KERNEL_GZIP=y +CONFIG_HAVE_KERNEL_LZMA=y +CONFIG_HAVE_KERNEL_LZO=y +# CONFIG_KERNEL_GZIP is not set +# CONFIG_KERNEL_LZMA is not set +CONFIG_KERNEL_LZO=y +CONFIG_DEFAULT_HOSTNAME="(none)" +# CONFIG_SWAP is not set +# CONFIG_SYSVIPC is not set +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_FHANDLE is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set +CONFIG_HAVE_GENERIC_HARDIRQS=y + +# +# IRQ subsystem +# +CONFIG_GENERIC_HARDIRQS=y +CONFIG_HAVE_SPARSE_IRQ=y +CONFIG_GENERIC_IRQ_SHOW=y +# CONFIG_SPARSE_IRQ is not set + +# +# RCU Subsystem +# +CONFIG_TREE_PREEMPT_RCU=y +# CONFIG_TINY_RCU is not set +# CONFIG_TINY_PREEMPT_RCU is not set +CONFIG_PREEMPT_RCU=y +# 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_RCU_BOOST is not set +# CONFIG_IKCONFIG is not set +CONFIG_LOG_BUF_SHIFT=19 +CONFIG_CGROUPS=y +CONFIG_CGROUP_DEBUG=y +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_BLK_CGROUP is not set +# CONFIG_NAMESPACES is not set +# CONFIG_SCHED_AUTOGROUP is not set +# CONFIG_SYSFS_DEPRECATED is not set +# CONFIG_RELAY 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_RD_XZ is not set +# CONFIG_RD_LZO is not set +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +CONFIG_PANIC_TIMEOUT=5 +CONFIG_EXPERT=y +CONFIG_UID16=y +# CONFIG_SYSCTL_SYSCALL is not set +CONFIG_KALLSYMS=y +# CONFIG_KALLSYMS_ALL 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 +CONFIG_EMBEDDED=y +CONFIG_HAVE_PERF_EVENTS=y +CONFIG_PERF_USE_VMALLOC=y + +# +# Kernel Performance Events And Counters +# +# CONFIG_PERF_EVENTS is not set +# CONFIG_PERF_COUNTERS is not set +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_REGS_AND_STACK_ACCESS_API=y +CONFIG_HAVE_CLK=y +CONFIG_HAVE_DMA_API_DEBUG=y + +# +# GCOV-based kernel profiling +# +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_DEADLINE is not set +CONFIG_IOSCHED_CFQ=y +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +# CONFIG_INLINE_SPIN_TRYLOCK is not set +# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set +# CONFIG_INLINE_SPIN_LOCK is not set +# CONFIG_INLINE_SPIN_LOCK_BH is not set +# CONFIG_INLINE_SPIN_LOCK_IRQ is not set +# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set +# CONFIG_INLINE_SPIN_UNLOCK is not set +# CONFIG_INLINE_SPIN_UNLOCK_BH is not set +# CONFIG_INLINE_SPIN_UNLOCK_IRQ is not set +# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set +# CONFIG_INLINE_READ_TRYLOCK is not set +# CONFIG_INLINE_READ_LOCK is not set +# CONFIG_INLINE_READ_LOCK_BH is not set +# CONFIG_INLINE_READ_LOCK_IRQ is not set +# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set +# CONFIG_INLINE_READ_UNLOCK is not set +# CONFIG_INLINE_READ_UNLOCK_BH is not set +# CONFIG_INLINE_READ_UNLOCK_IRQ is not set +# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set +# CONFIG_INLINE_WRITE_TRYLOCK is not set +# CONFIG_INLINE_WRITE_LOCK is not set +# CONFIG_INLINE_WRITE_LOCK_BH is not set +# CONFIG_INLINE_WRITE_LOCK_IRQ is not set +# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set +# CONFIG_INLINE_WRITE_UNLOCK is not set +# CONFIG_INLINE_WRITE_UNLOCK_BH is not set +# CONFIG_INLINE_WRITE_UNLOCK_IRQ is not set +# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set +# CONFIG_MUTEX_SPIN_ON_OWNER is not set +CONFIG_FREEZER=y + +# +# System Type +# +CONFIG_MMU=y +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_VEXPRESS is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_BCMRING is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_CNS3XXX 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_MXS is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X 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_DOVE is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_LPC32XX 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_W90X900 is not set +# CONFIG_ARCH_NUC93X is not set +# CONFIG_ARCH_TEGRA is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_MSM is not set +# CONFIG_ARCH_SHMOBILE 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_S5P64X0 is not set +# CONFIG_ARCH_S5PC100 is not set +# CONFIG_ARCH_S5PV210 is not set +# CONFIG_ARCH_EXYNOS4 is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_TCC_926 is not set +# CONFIG_ARCH_U300 is not set +# CONFIG_ARCH_U8500 is not set +# CONFIG_ARCH_NOMADIK is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +CONFIG_ARCH_RK29=y +# CONFIG_PLAT_SPEAR is not set +# CONFIG_ARCH_VT8500 is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_KEYBOARD_GPIO_POLLED is not set +# CONFIG_MACH_RK29SDK is not set +# CONFIG_MACH_RK29SDK_DDR3 is not set +# CONFIG_MACH_RK29WINACCORD is not set +CONFIG_MACH_RK29_K97=y +# 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_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_NEON_POWERDOMAIN_SET is not set +CONFIG_RK29_PWM_INSRAM=y + +# +# System MMU +# + +# +# Processor Type +# +CONFIG_CPU_V7=y +CONFIG_CPU_32v6K=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_SWP_EMULATE is not set +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_BPREDICT_DISABLE is not set +CONFIG_ARM_L1_CACHE_SHIFT_6=y +CONFIG_ARM_L1_CACHE_SHIFT=6 +CONFIG_ARM_DMA_MEM_BUFFERABLE=y +CONFIG_CPU_HAS_PMU=y +# CONFIG_ARM_ERRATA_430973 is not set +# CONFIG_ARM_ERRATA_458693 is not set +# CONFIG_ARM_ERRATA_460075 is not set +# CONFIG_ARM_ERRATA_743622 is not set +# CONFIG_ARM_ERRATA_754322 is not set +CONFIG_ARM_GIC=y +CONFIG_PL330=y +# CONFIG_FIQ_DEBUGGER is not set + +# +# 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_HAVE_ARCH_PFN_VALID=y +CONFIG_HIGHMEM=y +# CONFIG_HIGHPTE is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4 +# CONFIG_COMPACTION is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=1 +CONFIG_BOUNCE=y +CONFIG_VIRT_TO_BUS=y +# CONFIG_KSM is not set +CONFIG_DEFAULT_MMAP_MIN_ADDR=32768 +CONFIG_NEED_PER_CPU_KM=y +# CONFIG_CLEANCACHE is not set +CONFIG_FORCE_MAX_ZONEORDER=11 +CONFIG_ALIGNMENT_TRAP=y +# CONFIG_UACCESS_WITH_MEMCPY is not set +# CONFIG_SECCOMP is not set +# CONFIG_CC_STACKPROTECTOR is not set +# CONFIG_DEPRECATED_PARAM_STRUCT is not set +# CONFIG_ARM_FLUSH_CONSOLE_ON_RESTART is not set + +# +# Boot options +# +# CONFIG_USE_OF is not set +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 +# CONFIG_CRASH_DUMP is not set +# CONFIG_AUTO_ZRELADDR is not set + +# +# CPU Power Management +# + +# +# CPU Frequency scaling +# +CONFIG_CPU_FREQ=y +CONFIG_CPU_FREQ_TABLE=y +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_DEFAULT_GOV_INTERACTIVE 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_INTERACTIVE is not set +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_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_PM_SLEEP=y +# CONFIG_PM_RUNTIME is not set +CONFIG_PM=y +# CONFIG_PM_DEBUG is not set +# CONFIG_APM_EMULATION is not set +# CONFIG_SUSPEND_TIME is not set +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +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_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_DEMUX 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_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_SIT_6RD is not set +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_NET_ACTIVITY_STATS=y +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set +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_CONNTRACK_MARK=y +CONFIG_NF_CONNTRACK_EVENTS=y +# CONFIG_NF_CONNTRACK_TIMESTAMP is not set +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 +CONFIG_NF_CONNTRACK_FTP=y +CONFIG_NF_CONNTRACK_H323=y +CONFIG_NF_CONNTRACK_IRC=y +CONFIG_NF_CONNTRACK_BROADCAST=y +CONFIG_NF_CONNTRACK_NETBIOS_NS=y +# CONFIG_NF_CONNTRACK_SNMP is not set +CONFIG_NF_CONNTRACK_PPTP=y +CONFIG_NF_CONNTRACK_SANE=y +CONFIG_NF_CONNTRACK_SIP=y +CONFIG_NF_CONNTRACK_TFTP=y +CONFIG_NF_CT_NETLINK=y +CONFIG_NETFILTER_XTABLES=y + +# +# Xtables combined modules +# +CONFIG_NETFILTER_XT_MARK=y +CONFIG_NETFILTER_XT_CONNMARK=y + +# +# Xtables targets +# +CONFIG_NETFILTER_XT_TARGET_CLASSIFY=y +CONFIG_NETFILTER_XT_TARGET_CONNMARK=y +# CONFIG_NETFILTER_XT_TARGET_IDLETIMER is not set +CONFIG_NETFILTER_XT_TARGET_MARK=y +# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set +CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y +# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set +# CONFIG_NETFILTER_XT_TARGET_TEE is not set +# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set + +# +# Xtables matches +# +# CONFIG_NETFILTER_XT_MATCH_ADDRTYPE is not set +# CONFIG_NETFILTER_XT_MATCH_CLUSTER is not set +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_CPU is not set +# CONFIG_NETFILTER_XT_MATCH_DCCP is not set +# CONFIG_NETFILTER_XT_MATCH_DEVGROUP 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_OSF is not set +# CONFIG_NETFILTER_XT_MATCH_OWNER is not set +# CONFIG_NETFILTER_XT_MATCH_POLICY is not set +CONFIG_NETFILTER_XT_MATCH_PKTTYPE=y +CONFIG_NETFILTER_XT_MATCH_QUOTA=y +# CONFIG_NETFILTER_XT_MATCH_QUOTA2 is not set +# 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_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_IP_SET 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_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 is not set +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_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_RAW is not set +CONFIG_IP_NF_ARPTABLES=y +CONFIG_IP_NF_ARPFILTER=y +CONFIG_IP_NF_ARP_MANGLE=y + +# +# IPv6: Netfilter Configuration +# +# CONFIG_NF_DEFRAG_IPV6 is not set +# 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_L2TP 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 +# CONFIG_BATMAN_ADV 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_ATH3K 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_WIRELESS_EXT=y +CONFIG_WEXT_CORE=y +CONFIG_WEXT_PROC=y +CONFIG_WEXT_PRIV=y +# CONFIG_CFG80211 is not set +CONFIG_WIRELESS_EXT_SYSFS=y +# CONFIG_LIB80211 is not set + +# +# CFG80211 needs to be enabled for MAC80211 +# +# CONFIG_WIMAX is not set +CONFIG_RFKILL=y +# CONFIG_RFKILL_PM is not set +# CONFIG_RFKILL_INPUT is not set +# CONFIG_RFKILL_REGULATOR is not set +# CONFIG_RFKILL_GPIO is not set +# CONFIG_NET_9P is not set +# CONFIG_CAIF is not set +# CONFIG_CEPH_LIB 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_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_SM_FTL 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 +# 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 + +# +# DRBD disabled because PROC_FS, INET or CONNECTOR not selected +# +# 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_BLK_DEV_RBD is not set +# CONFIG_SENSORS_LIS3LV02D is not set +CONFIG_MISC_DEVICES=y +# CONFIG_AD525X_DPOT is not set +CONFIG_ANDROID_PMEM=y +# CONFIG_INTEL_MID_PTI is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_KERNEL_DEBUGGER_CORE is not set +# CONFIG_APDS9802ALS is not set +# CONFIG_ISL29003 is not set +# CONFIG_ISL29020 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_SENSORS_BH1780 is not set +# CONFIG_SENSORS_BH1770 is not set +# CONFIG_SENSORS_APDS990X is not set +# CONFIG_HMC6352 is not set +# CONFIG_SENSORS_AK8975 is not set +# CONFIG_DS1682 is not set +CONFIG_UID_STAT=y +# CONFIG_BMP085 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_FM580X is not set +# CONFIG_MU509 is not set +# CONFIG_MW100 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_SENSORS_MPU3050 is not set +# CONFIG_MPU_SENSORS_MPU6000 is not set +# CONFIG_MPU_SENSORS_TIMERIRQ is not set +# CONFIG_IWMC3200TOP is not set + +# +# Texas Instruments shared transport line discipline +# +# CONFIG_TI_ST is not set +# CONFIG_SENSORS_LIS3_I2C is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +CONFIG_SCSI_MOD=y +# 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_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_ISCSI_BOOT_SYSFS 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_RAID 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_DM_FLAKEY is not set +# CONFIG_TARGET_CORE is not set +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_MII=y +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_MICREL_PHY is not set +# CONFIG_FIXED_PHY is not set +# CONFIG_MDIO_BITBANG is not set +CONFIG_NET_ETHERNET=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_KS8851_MLL is not set +# CONFIG_FTMAC100 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 +# CONFIG_RTL8192CU 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_USB_IPHETH is not set +# CONFIG_WAN is not set + +# +# CAIF transport drivers +# +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_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 +# CONFIG_INPUT_SPARSEKMAP is not set + +# +# 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_ADP5589 is not set +# CONFIG_KEYBOARD_ATKBD is not set +# CONFIG_KEYBOARD_QT1070 is not set +# CONFIG_KEYBOARD_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_TCA6416 is not set +# CONFIG_KEYBOARD_MATRIX is not set +# CONFIG_KEYBOARD_MAX7359 is not set +# CONFIG_KEYBOARD_MCS is not set +# CONFIG_KEYBOARD_MPR121 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_GT8XX=y +# CONFIG_TOUCHSCREEN_IT7250 is not set +# CONFIG_TOUCHSCREEN_AD7879 is not set +# CONFIG_TOUCHSCREEN_ATMEL_MXT is not set +# CONFIG_TOUCHSCREEN_BU21013 is not set +# CONFIG_TOUCHSCREEN_CY8CTMG110 is not set +# CONFIG_TOUCHSCREEN_DYNAPRO is not set +# CONFIG_TOUCHSCREEN_HAMPSHIRE 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_MAX11801 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_TOUCHSCREEN_ST1232 is not set +# CONFIG_TOUCHSCREEN_TPS6507X 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_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_AD714X 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_PCF8574 is not set +# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set +# CONFIG_INPUT_ADXL34X is not set +# CONFIG_INPUT_CMA3000 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_UNIX98_PTYS=y +# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set +# CONFIG_LEGACY_PTYS is not set +# CONFIG_SERIAL_NONSTANDARD is not set +# CONFIG_N_GSM is not set +# CONFIG_TRACE_SINK is not set +CONFIG_DEVMEM=y +CONFIG_DEVKMEM=y + +# +# Serial drivers +# +# CONFIG_SERIAL_8250 is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +# CONFIG_SERIAL_TIMBERDALE is not set +CONFIG_SERIAL_RK29=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_SERIAL_ALTERA_JTAGUART is not set +# CONFIG_SERIAL_ALTERA_UART is not set +# CONFIG_SERIAL_XILINX_PS_UART is not set +# CONFIG_TTY_PRINTK is not set +# CONFIG_HVC_DCC 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_RAMOOPS is not set +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_COMPAT=y +# CONFIG_I2C_CHARDEV is not set +# CONFIG_I2C_MUX is not set +CONFIG_I2C_HELPER_AUTO=y + +# +# I2C Hardware Bus support +# + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_DESIGNWARE is not set +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_PXA_PCI is not set +# CONFIG_I2C_SIMTEC is not set +# CONFIG_I2C_XILINX is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_DIOLAN_U2C is not set +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_STUB is not set +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 +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS 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 + +# +# PPS generators support +# + +# +# PTP clock support +# + +# +# Enable Device Drivers -> PPS to see the PTP clock options. +# +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +# CONFIG_DEBUG_GPIO is not set +# CONFIG_GPIO_SYSFS is not set + +# +# Memory mapped GPIO drivers: +# +# CONFIG_GPIO_BASIC_MMIO is not set +# CONFIG_GPIO_IT8761E is not set + +# +# I2C GPIO expanders: +# +# CONFIG_GPIO_MAX7300 is not set +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCF857X is not set +# CONFIG_GPIO_SX150X is not set +# CONFIG_GPIO_ADP5588 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 + +# +# MODULbus GPIO expanders: +# +# CONFIG_W1 is not set +CONFIG_POWER_SUPPLY=y +# CONFIG_POWER_SUPPLY_DEBUG is not set +# CONFIG_PDA_POWER is not set +# CONFIG_TEST_POWER is not set +# CONFIG_BATTERY_DS2780 is not set +# CONFIG_BATTERY_DS2782 is not set +# CONFIG_BATTERY_BQ20Z75 is not set +# CONFIG_BATTERY_BQ27x00 is not set +# CONFIG_BATTERY_MAX17040 is not set +# CONFIG_BATTERY_MAX17042 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_CHARGER_MAX8903 is not set +# CONFIG_CHARGER_GPIO 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 +CONFIG_BCMA_POSSIBLE=y + +# +# Broadcom specific AMBA +# +# CONFIG_BCMA is not set +CONFIG_MFD_SUPPORT=y +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_88PM860X 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_HTC_I2CPLD is not set +# CONFIG_TPS6105X is not set +# CONFIG_TPS65010 is not set +# CONFIG_TPS6507X is not set +# CONFIG_MFD_TPS6586X is not set +# CONFIG_TWL4030_CORE is not set +# CONFIG_MFD_STMPE is not set +# CONFIG_MFD_TC3589X 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_PMIC_ADP5520 is not set +# CONFIG_MFD_MAX8925 is not set +# CONFIG_MFD_MAX8997 is not set +# CONFIG_MFD_MAX8998 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_WM8994 is not set +# CONFIG_MFD_PCF50633 is not set +# CONFIG_ABX500_CORE is not set +# CONFIG_MFD_WL1273_CORE is not set +# CONFIG_MFD_TPS65910 is not set +CONFIG_REGULATOR=y +# CONFIG_REGULATOR_DEBUG is not set +# CONFIG_REGULATOR_DUMMY 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_MAX8649 is not set +# CONFIG_REGULATOR_MAX8660 is not set +# CONFIG_REGULATOR_MAX8952 is not set +# CONFIG_REGULATOR_LP3971 is not set +# CONFIG_REGULATOR_LP3972 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_REGULATOR_ISL6271A is not set +# CONFIG_REGULATOR_AD5398 is not set +CONFIG_MEDIA_SUPPORT=y + +# +# Multimedia core support +# +# CONFIG_MEDIA_CONTROLLER is not set +CONFIG_VIDEO_DEV=y +CONFIG_VIDEO_V4L2_COMMON=y +# CONFIG_DVB_CORE is not set +CONFIG_VIDEO_MEDIA=y + +# +# Multimedia drivers +# +CONFIG_RC_CORE=y +CONFIG_LIRC=y +CONFIG_RC_MAP=y +CONFIG_IR_NEC_DECODER=y +CONFIG_IR_RC5_DECODER=y +CONFIG_IR_RC6_DECODER=y +CONFIG_IR_JVC_DECODER=y +CONFIG_IR_SONY_DECODER=y +CONFIG_IR_RC5_SZ_DECODER=y +CONFIG_IR_LIRC_CODEC=y +# CONFIG_IR_IMON is not set +# CONFIG_IR_MCEUSB is not set +# CONFIG_IR_REDRAT3 is not set +# CONFIG_IR_STREAMZAP is not set +# CONFIG_RC_LOOPBACK is not set +# 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_TDA827X=y +CONFIG_MEDIA_TUNER_TDA18271=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_VIDEOBUF_GEN=y +CONFIG_VIDEOBUF_DMA_CONTIG=y +CONFIG_VIDEOBUF2_CORE=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_IR_I2C=y + +# +# Audio decoders, processors and mixers +# + +# +# RDS decoders +# + +# +# Video decoders +# + +# +# Video and audio decoders +# + +# +# MPEG video encoders +# + +# +# Video encoders +# + +# +# Camera sensor devices +# + +# +# Video improvement chips +# + +# +# Miscelaneous helper chips +# +# CONFIG_VIDEO_CPIA2 is not set +# CONFIG_VIDEO_SR030PC30 is not set +# CONFIG_VIDEO_NOON010PC30 is not set +CONFIG_SOC_CAMERA=y +# CONFIG_SOC_CAMERA_IMX074 is not set +# 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_MT9T112 is not set +# CONFIG_SOC_CAMERA_MT9V022 is not set +# CONFIG_SOC_CAMERA_RJ54N1 is not set +# CONFIG_SOC_CAMERA_TW9910 is not set +# CONFIG_SOC_CAMERA_PLATFORM is not set +# CONFIG_SOC_CAMERA_OV2640 is not set +# CONFIG_SOC_CAMERA_OV6650 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_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_SOC_CAMERA_OV9640 is not set +# CONFIG_SOC_CAMERA_OV9740 is not set +# CONFIG_VIDEO_SH_MOBILE_CSI2 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_VIDEO_RK29_DIGITALZOOM_IPP_ON=y +# CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_OFF 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_BENQ is not set +# CONFIG_USB_GSPCA_CONEX is not set +# CONFIG_USB_GSPCA_CPIA1 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_KINECT is not set +# CONFIG_USB_GSPCA_KONICA is not set +# CONFIG_USB_GSPCA_MARS is not set +# CONFIG_USB_GSPCA_MR97310A is not set +# CONFIG_USB_GSPCA_NW80X is not set +# CONFIG_USB_GSPCA_OV519 is not set +# CONFIG_USB_GSPCA_OV534 is not set +# CONFIG_USB_GSPCA_OV534_9 is not set +# CONFIG_USB_GSPCA_PAC207 is not set +# CONFIG_USB_GSPCA_PAC7302 is not set +# CONFIG_USB_GSPCA_PAC7311 is not set +# CONFIG_USB_GSPCA_SN9C2028 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_SPCA1528 is not set +# CONFIG_USB_GSPCA_SQ905 is not set +# CONFIG_USB_GSPCA_SQ905C is not set +# CONFIG_USB_GSPCA_SQ930X is not set +# CONFIG_USB_GSPCA_STK014 is not set +# CONFIG_USB_GSPCA_STV0680 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_VICAM is not set +# CONFIG_USB_GSPCA_XIRLINK_CIT 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_ET61X251 is not set +# CONFIG_USB_SN9C102 is not set +# CONFIG_USB_PWC is not set +# CONFIG_USB_ZR364XX is not set +# CONFIG_USB_STKWEBCAM is not set +# CONFIG_USB_S2255 is not set +# CONFIG_V4L_MEM2MEM_DRIVERS 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_RADIO_SAA7706H is not set +# CONFIG_RADIO_TEF6862 is not set +# CONFIG_RADIO_WL1273 is not set + +# +# Texas Instruments WL128x FM driver (ST based) +# +# CONFIG_RADIO_WL128X is not set +# CONFIG_SMS_SIANO_MDTV is not set + +# +# Graphics support +# +# CONFIG_DRM is not set +# CONFIG_ION is not set +# 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_WMT_GE_ROPS 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_RK29=y +CONFIG_FB_WORK_IPP=y +CONFIG_FB_SCALING_OSD=y +# CONFIG_FB_SCALING_OSD_1080P is not set +# CONFIG_FB_ROTATE_VIDEO is not set +CONFIG_CLOSE_WIN1_DYNAMIC=y +# CONFIG_FB_UDL is not set +# CONFIG_FB_VIRTUAL is not set +# CONFIG_FB_METRONOME 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 +# CONFIG_BACKLIGHT_ADP8860 is not set +# CONFIG_BACKLIGHT_ADP8870 is not set + +# +# Display device support +# +CONFIG_DISPLAY_SUPPORT=y + +# +# Display hardware drivers +# +# CONFIG_LCD_NULL is not set +CONFIG_LCD_LG_LP097X02=y +# 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_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_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_UA101 is not set +# CONFIG_SND_USB_CAIAQ is not set +# CONFIG_SND_USB_6FIRE is not set +CONFIG_SND_SOC=y +# CONFIG_SND_SOC_CACHE_LZO is not set +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_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 +# 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_RT5631=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_ACRUX 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_EMS_FF is not set +# CONFIG_HID_EZKEY is not set +# CONFIG_HID_KEYTOUCH is not set +# CONFIG_HID_KYE is not set +# CONFIG_HID_UCLOGIC is not set +# CONFIG_HID_WALTOP is not set +# CONFIG_HID_GYRATION is not set +# CONFIG_HID_TWINHAN is not set +# CONFIG_HID_KENSINGTON is not set +# CONFIG_HID_LCPOWER is not set +# CONFIG_HID_LOGITECH is not set +# CONFIG_HID_MICROSOFT is not set +# CONFIG_HID_MONTEREY is not set +# CONFIG_HID_MULTITOUCH is not set +# CONFIG_HID_NTRIG is not set +# CONFIG_HID_ORTEK is not set +# CONFIG_HID_PANTHERLORD is not set +# CONFIG_HID_PETALYNX is not set +# CONFIG_HID_PICOLCD is not set +# CONFIG_HID_QUANTA is not set +# CONFIG_HID_ROCCAT is not set +# CONFIG_HID_ROCCAT_ARVO is not set +# CONFIG_HID_ROCCAT_KONE is not set +# CONFIG_HID_ROCCAT_KONEPLUS is not set +# CONFIG_HID_ROCCAT_KOVAPLUS is not set +# CONFIG_HID_ROCCAT_PYRA 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_HID_ZYDACRON 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_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 + +# +# 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_REALTEK 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_STORAGE_ENE_UB6250 is not set +# CONFIG_USB_UAS 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_QCAUX 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_WWAN=y +CONFIG_USB_SERIAL_OPTION=y +# CONFIG_USB_SERIAL_OMNINET is not set +# CONFIG_USB_SERIAL_OPTICON is not set +# CONFIG_USB_SERIAL_VIVOPAY_SERIAL is not set +# CONFIG_USB_SERIAL_ZIO is not set +# CONFIG_USB_SERIAL_SSU100 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_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_YUREX 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_FUSB300 is not set +# CONFIG_USB_GADGET_R8A66597 is not set +# CONFIG_USB_GADGET_PXA_U2O is not set +# CONFIG_USB_GADGET_M66592 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_ETH is not set +# CONFIG_USB_G_NCM is not set +# CONFIG_USB_GADGETFS is not set +# CONFIG_USB_FUNCTIONFS is not set +# CONFIG_USB_FILE_STORAGE is not set +# CONFIG_USB_MASS_STORAGE is not set +# CONFIG_USB_G_SERIAL is not set +# CONFIG_USB_G_PRINTER is not set +CONFIG_USB_G_ANDROID=y +# CONFIG_USB_CDC_COMPOSITE is not set +# CONFIG_USB_G_MULTI is not set +# CONFIG_USB_G_HID is not set +# CONFIG_USB_G_DBGP is not set +# CONFIG_USB_G_WEBCAM is not set + +# +# OTG and related infrastructure +# +# CONFIG_USB_OTG_WAKELOCK is not set +# CONFIG_USB_GPIO_VBUS is not set +# CONFIG_USB_ULPI 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_CLKGATE is not set +CONFIG_MMC_EMBEDDED_SDIO=y +CONFIG_MMC_PARANOID_SD_INIT=y + +# +# MMC/SD/SDIO Card Drivers +# +CONFIG_MMC_BLOCK=y +CONFIG_MMC_BLOCK_MINORS=8 +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_SDMMC0_RK29_WRITE_PROTECT is not set +CONFIG_SDMMC1_RK29=y +# CONFIG_SDMMC1_RK29_WRITE_PROTECT is not set +# CONFIG_MMC_SDHCI is not set +# CONFIG_MMC_DW is not set +# CONFIG_MMC_VUB300 is not set +# CONFIG_MMC_USHC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_NEW_LEDS is not set +# CONFIG_NFC_DEVICES 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_DS3232 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_ISL12022 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_BQ32K 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 +# CONFIG_RTC_DRV_EM3027 is not set +# CONFIG_RTC_DRV_RV3029C2 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_MSM6242 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_RP5C01 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 +CONFIG_STAGING=y +# CONFIG_VIDEO_TM6000 is not set +# CONFIG_USBIP_CORE is not set +# CONFIG_ECHO is not set +# CONFIG_BRCMUTIL is not set +# CONFIG_ASUS_OLED is not set +# CONFIG_R8712U 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_POHMELFS is not set +# CONFIG_USB_SERIAL_QUATECH2 is not set +# CONFIG_USB_SERIAL_QUATECH_USB2 is not set +# CONFIG_VT6656 is not set +# CONFIG_IIO is not set + +# +# GPU Vivante +# +CONFIG_VIVANTE=y + +# +# IPP +# +CONFIG_RK29_IPP=y +CONFIG_DEINTERLACE=y +# CONFIG_XVMALLOC is not set +# CONFIG_ZRAM is not set +# CONFIG_FB_SM7XX is not set +# CONFIG_LIRC_STAGING is not set +CONFIG_MACH_NO_WESTBRIDGE=y +# CONFIG_USB_ENESTORAGE is not set +# CONFIG_BCM_WIMAX is not set +# CONFIG_FT1000 is not set + +# +# Speakup console speech +# +# CONFIG_SPEAKUP is not set +# CONFIG_TOUCHSCREEN_CLEARPAD_TM1217 is not set +# CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4 is not set + +# +# Altera FPGA firmware download module +# +# CONFIG_ALTERA_STAPL is not set +CONFIG_CLKDEV_LOOKUP=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_USE_FOR_EXT23=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_XFS_FS is not set +# CONFIG_BTRFS_FS is not set +# CONFIG_NILFS2_FS is not set +# CONFIG_FS_POSIX_ACL is not set +CONFIG_FILE_LOCKING=y +CONFIG_FSNOTIFY=y +# CONFIG_DNOTIFY is not set +CONFIG_INOTIFY_USER=y +# CONFIG_FANOTIFY is not set +# CONFIG_QUOTA is not set +# CONFIG_QUOTACTL 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_TMPFS_XATTR 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_LOGFS 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_PSTORE 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 + +# +# Kernel hacking +# +CONFIG_PRINTK_TIME=y +CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4 +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_SECTION_MISMATCH is not set +CONFIG_DEBUG_KERNEL=y +# CONFIG_DEBUG_SHIRQ is not set +# CONFIG_LOCKUP_DETECTOR is not set +# CONFIG_HARDLOCKUP_DETECTOR is not set +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120 +# 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_SPARSE_RCU_POINTER 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_STACKTRACE=y +# CONFIG_DEBUG_STACK_USAGE 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_TEST_LIST_SORT 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_TIMEOUT=60 +CONFIG_RCU_CPU_STALL_VERBOSE=y +# 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_SYSCTL_SYSCALL_CHECK is not set +# CONFIG_DEBUG_PAGEALLOC is not set +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_TRACING_SUPPORT=y +# CONFIG_FTRACE is not set +# CONFIG_DMA_API_DEBUG is not set +# CONFIG_ATOMIC64_SELFTEST is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_KGDB is not set +# CONFIG_TEST_KSTRTOX is not set +# CONFIG_STRICT_DEVMEM is not set +CONFIG_ARM_UNWIND=y +# CONFIG_DEBUG_USER is not set +# CONFIG_DEBUG_LL is not set +# CONFIG_OC_ETM is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY_DMESG_RESTRICT is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +CONFIG_DEFAULT_SECURITY_DAC=y +CONFIG_DEFAULT_SECURITY="" +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_PCOMP2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=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=y +# 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_USER_API_HASH is not set +# CONFIG_CRYPTO_USER_API_SKCIPHER is not set +CONFIG_CRYPTO_HW=y +# CONFIG_BINARY_PRINTF is not set + +# +# Library routines +# +CONFIG_BITREVERSE=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_XZ_DEC is not set +# CONFIG_XZ_DEC_BCJ is not set +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 +# CONFIG_AVERAGE is not set diff --git a/arch/arm/configs/rk29_phonesdk_defconfig b/arch/arm/configs/rk29_phonesdk_defconfig index 89ed26a541bd..5a094da7cbaf 100755 --- a/arch/arm/configs/rk29_phonesdk_defconfig +++ b/arch/arm/configs/rk29_phonesdk_defconfig @@ -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 index 000000000000..f6ab3eb778fa --- /dev/null +++ b/arch/arm/configs/rk29_td8801_v2_defconfig @@ -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 diff --git a/arch/arm/mach-rk29/Kconfig b/arch/arm/mach-rk29/Kconfig index cfde2d8ab54d..22fa6e1aa384 100644 --- a/arch/arm/mach-rk29/Kconfig +++ b/arch/arm/mach-rk29/Kconfig @@ -23,6 +23,12 @@ config MACH_RK29WINACCORD help Support for the ROCKCHIP Board For Rk29 Winaccord. +config MACH_RK29_K97 + depends on ARCH_RK29 + bool "ROCKCHIP Board Rk29 For K97" + help + Support for the ROCKCHIP Board For Rk29 K97. + config MACH_RK29FIH depends on ARCH_RK29 bool "ROCKCHIP Board Rk29 For FIH" @@ -47,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" diff --git a/arch/arm/mach-rk29/Makefile b/arch/arm/mach-rk29/Makefile index df2e7a0b3c26..ad27049352af 100644 --- a/arch/arm/mach-rk29/Makefile +++ b/arch/arm/mach-rk29/Makefile @@ -21,6 +21,8 @@ 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 diff --git a/arch/arm/mach-rk29/board-rk29-ddr3sdk.c b/arch/arm/mach-rk29/board-rk29-ddr3sdk.c index b589b176341f..a1ee2b087fba 100755 --- a/arch/arm/mach-rk29/board-rk29-ddr3sdk.c +++ b/arch/arm/mach-rk29/board-rk29-ddr3sdk.c @@ -71,6 +71,7 @@ #define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */ #define CONFIG_SENSOR_IIC_ADDR_0 0x78 #define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1 +#define CONFIG_SENSOR_ORIENTATION_0 0 #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 @@ -83,6 +84,7 @@ #define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */ #define CONFIG_SENSOR_IIC_ADDR_1 0x60 #define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1 +#define CONFIG_SENSOR_ORIENTATION_1 0 #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 @@ -1411,14 +1413,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 +1434,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", diff --git a/arch/arm/mach-rk29/board-rk29-k97.c b/arch/arm/mach-rk29/board-rk29-k97.c new file mode 100755 index 000000000000..58509d254253 --- /dev/null +++ b/arch/arm/mach-rk29/board-rk29-k97.c @@ -0,0 +1,3075 @@ +/* arch/arm/mach-rk29/board-rk29.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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_USB_ANDROID +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include /* ddl@rock-chips.com : camera support */ +#include /* ddl@rock-chips.com : camera support */ +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include "devices.h" +#include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h" + +#ifdef CONFIG_BU92747GUW_CIR +#include "../../../drivers/cir/bu92747guw_cir.h" +#endif +#ifdef CONFIG_VIDEO_RK29 +/*---------------- Camera Sensor Macro Define Begin ------------------------*/ +/*---------------- Camera Sensor Configuration Macro Begin ------------------------*/ +#define CONFIG_SENSOR_0 RK29_CAM_SENSOR_OV5642 /* back camera sensor */ +#define CONFIG_SENSOR_IIC_ADDR_0 0x78 +#define CONFIG_SENSOR_IIC_ADAPTER_ID_0 1 +#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 INVALID_GPIO +#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_L + +#define CONFIG_SENSOR_1 RK29_CAM_SENSOR_OV2659 /* front camera sensor */ +#define CONFIG_SENSOR_IIC_ADDR_1 0x60 +#define CONFIG_SENSOR_IIC_ADAPTER_ID_1 1 +#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 +#endif //#ifdef CONFIG_VIDEO_RK29 +/*---------------- Camera Sensor Configuration Macro End------------------------*/ +#include "../../../drivers/media/video/rk29_camera.c" +/*---------------- Camera Sensor Macro Define End ------------------------*/ + + +/* 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_16M +#define PMEM_UI_SIZE (48 * SZ_1M) /* 1280x800: 64M 1024x768: 48M ... */ +#define PMEM_VPU_SIZE SZ_64M +#define PMEM_SKYPE_SIZE 0 +#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 (9*SZ_1M) +#ifdef CONFIG_FB_WORK_IPP +#ifdef CONFIG_FB_SCALING_OSD_1080P +#define MEM_FBIPP_SIZE SZ_16M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4 +#else +#define MEM_FBIPP_SIZE SZ_8M //1920 x 1080 x 2 x 2 //RGB565 = x2;RGB888 = x4 +#endif +#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 PMEM_SKYPE_BASE (MEM_FBIPP_BASE - PMEM_SKYPE_SIZE) +#define LINUX_SIZE (PMEM_SKYPE_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 + +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, +}; + +#define TOUCH_SCREEN_STANDBY_PIN RK29_PIN6_PD1 +#define TOUCH_SCREEN_STANDBY_VALUE GPIO_HIGH +#define TOUCH_SCREEN_DISPLAY_PIN INVALID_GPIO +#define TOUCH_SCREEN_DISPLAY_VALUE GPIO_HIGH + +#ifdef CONFIG_FB_RK29 +/***************************************************************************************** + * lcd devices + * author: zyw@rock-chips.com + *****************************************************************************************/ +//#ifdef CONFIG_LCD_TD043MGEA1 +#define LCD_TXD_PIN INVALID_GPIO +#define LCD_CLK_PIN INVALID_GPIO +#define LCD_CS_PIN INVALID_GPIO +/***************************************************************************************** +* frame buffe 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 +#define FB_LCD_CABC_EN_PIN RK29_PIN6_PD2 +#define FB_MCU_FMK_PIN INVALID_GPIO + +#define FB_DISPLAY_ON_VALUE GPIO_HIGH +#define FB_LCD_STANDBY_VALUE GPIO_HIGH + +static int rk29_lcd_io_init(void) +{ + int ret = 0; + return ret; +} + +static int rk29_lcd_io_deinit(void) +{ + int ret = 0; + 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) + { + if(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 "); + } + } + else if (TOUCH_SCREEN_DISPLAY_PIN != INVALID_GPIO) + { + ret = gpio_request(TOUCH_SCREEN_DISPLAY_PIN, NULL); + if(ret != 0) + { + gpio_free(TOUCH_SCREEN_DISPLAY_PIN); + printk(">>>>>> TOUCH_SCREEN_DISPLAY_PIN gpio_request err \n "); + } + gpio_direction_output(TOUCH_SCREEN_DISPLAY_PIN, 0); + gpio_set_value(TOUCH_SCREEN_DISPLAY_PIN, TOUCH_SCREEN_DISPLAY_VALUE); + } + } + + if(fb_setting->disp_on_en) + { + if(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 "); + } + } + else if (TOUCH_SCREEN_STANDBY_PIN != INVALID_GPIO) + { + ret = gpio_request(TOUCH_SCREEN_STANDBY_PIN, NULL); + if(ret != 0) + { + gpio_free(TOUCH_SCREEN_STANDBY_PIN); + printk(">>>>>> TOUCH_SCREEN_STANDBY_PIN gpio_request err \n "); + } + gpio_direction_output(TOUCH_SCREEN_STANDBY_PIN, 0); + gpio_set_value(TOUCH_SCREEN_STANDBY_PIN, TOUCH_SCREEN_STANDBY_VALUE); + } + } + + 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 + +#if defined(CONFIG_RK29_GPIO_SUSPEND) +static void key_gpio_pullupdown_enable(void) +{ + gpio_pull_updown(RK29_PIN6_PA0, 0); + gpio_pull_updown(RK29_PIN6_PA1, 0); + gpio_pull_updown(RK29_PIN6_PA2, 0); + gpio_pull_updown(RK29_PIN6_PA3, 0); + gpio_pull_updown(RK29_PIN6_PA4, 0); + gpio_pull_updown(RK29_PIN6_PA5, 0); + gpio_pull_updown(RK29_PIN6_PA6, 0); +} + +static void key_gpio_pullupdown_disable(void) +{ + gpio_pull_updown(RK29_PIN6_PA0, 1); + gpio_pull_updown(RK29_PIN6_PA1, 1); + gpio_pull_updown(RK29_PIN6_PA2, 1); + gpio_pull_updown(RK29_PIN6_PA3, 1); + gpio_pull_updown(RK29_PIN6_PA4, 1); + gpio_pull_updown(RK29_PIN6_PA5, 1); + gpio_pull_updown(RK29_PIN6_PA6, 1); +} + +void rk29_setgpio_suspend_board(void) +{ + key_gpio_pullupdown_enable(); +} + +void rk29_setgpio_resume_board(void) +{ + key_gpio_pullupdown_disable(); +} +#endif + +#if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR) +#define BU92747GUW_RESET_PIN RK29_PIN3_PD4// INVALID_GPIO // +#define BU92747GUW_RESET_MUX_NAME GPIO3D4_HOSTWRN_NAME//NULL // +#define BU92747GUW_RESET_MUX_MODE GPIO3H_GPIO3D4//NULL // + +#define BU92747GUW_PWDN_PIN RK29_PIN3_PD3//RK29_PIN5_PA7 // +#define BU92747GUW_PWDN_MUX_NAME GPIO3D3_HOSTRDN_NAME//GPIO5A7_HSADCDATA2_NAME // +#define BU92747GUW_PWDN_MUX_MODE GPIO3H_GPIO3D3//GPIO5L_GPIO5A7 // + +static int bu92747guw_io_init(void) +{ + int ret; + + //reset pin + if(BU92747GUW_RESET_MUX_NAME != NULL) + { + rk29_mux_api_set(BU92747GUW_RESET_MUX_NAME, BU92747GUW_RESET_MUX_MODE); + } + ret = gpio_request(BU92747GUW_RESET_PIN, NULL); + if(ret != 0) + { + gpio_free(BU92747GUW_RESET_PIN); + printk(">>>>>> BU92747GUW_RESET_PIN gpio_request err \n "); + } + gpio_direction_output(BU92747GUW_RESET_PIN, GPIO_HIGH); + + //power down pin + if(BU92747GUW_PWDN_MUX_NAME != NULL) + { + rk29_mux_api_set(BU92747GUW_PWDN_MUX_NAME, BU92747GUW_PWDN_MUX_MODE); + } + ret = gpio_request(BU92747GUW_PWDN_PIN, NULL); + if(ret != 0) + { + gpio_free(BU92747GUW_PWDN_PIN); + printk(">>>>>> BU92747GUW_PWDN_PIN gpio_request err \n "); + } + + //power down as default + gpio_direction_output(BU92747GUW_PWDN_PIN, GPIO_LOW); + + return 0; +} + + +static int bu92747guw_io_deinit(void) +{ + gpio_free(BU92747GUW_PWDN_PIN); + gpio_free(BU92747GUW_RESET_PIN); + return 0; +} + +//power ctl func is share with irda and remote +static int nPowerOnCount = 0; +static DEFINE_MUTEX(bu92747_power_mutex); + +//1---power on; 0---power off +static int bu92747guw_power_ctl(int enable) +{ + printk("%s \n",__FUNCTION__); + + mutex_lock(&bu92747_power_mutex); + if (enable) { + nPowerOnCount++; + if (nPowerOnCount == 1) {//power on first + //smc0_init(NULL); + gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_HIGH); + gpio_set_value(BU92747GUW_RESET_PIN, GPIO_LOW); + mdelay(5); + gpio_set_value(BU92747GUW_RESET_PIN, GPIO_HIGH); + mdelay(5); + } + } + else { + nPowerOnCount--; + if (nPowerOnCount <= 0) {//power down final + nPowerOnCount = 0; + //smc0_exit(); + gpio_set_value(BU92747GUW_PWDN_PIN, GPIO_LOW); + } + } + mutex_unlock(&bu92747_power_mutex); + return 0; +} +#endif + +#ifdef CONFIG_RK_IRDA +#define IRDA_IRQ_PIN RK29_PIN5_PB2 +#define IRDA_IRQ_MUX_NAME GPIO5B2_HSADCDATA5_NAME +#define IRDA_IRQ_MUX_MODE GPIO5L_GPIO5B2 + +int irda_iomux_init(void) +{ + int ret = 0; + + //irda irq pin + if(IRDA_IRQ_MUX_NAME != NULL) + { + rk29_mux_api_set(IRDA_IRQ_MUX_NAME, IRDA_IRQ_MUX_MODE); + } + ret = gpio_request(IRDA_IRQ_PIN, NULL); + if(ret != 0) + { + gpio_free(IRDA_IRQ_PIN); + printk(">>>>>> IRDA_IRQ_PIN gpio_request err \n "); + } + gpio_pull_updown(IRDA_IRQ_PIN, GPIO_HIGH); + gpio_direction_input(IRDA_IRQ_PIN); + + return 0; +} + +int irda_iomux_deinit(void) +{ + gpio_free(IRDA_IRQ_PIN); + return 0; +} + +static struct irda_info rk29_irda_info = { + .intr_pin = IRDA_IRQ_PIN, + .iomux_init = irda_iomux_init, + .iomux_deinit = irda_iomux_deinit, + .irda_pwr_ctl = bu92747guw_power_ctl, +}; + +static struct platform_device irda_device = { +#ifdef CONFIG_RK_IRDA_NET + .name = "rk_irda", +#else + .name = "bu92747_irda", +#endif + .id = -1, + .dev = { + .platform_data = &rk29_irda_info, + } +}; +#endif + +#ifdef CONFIG_BU92747GUW_CIR +#define BU92747_CIR_IRQ_PIN RK29_PIN5_PB0 +#define CIR_IRQ_PIN_IOMUX_NAME GPIO5B0_HSADCDATA3_NAME +#define CIR_IRQ_PIN_IOMUX_VALUE GPIO5L_GPIO5B0 +static int cir_iomux_init(void) +{ + if (CIR_IRQ_PIN_IOMUX_NAME) + rk29_mux_api_set(CIR_IRQ_PIN_IOMUX_NAME, CIR_IRQ_PIN_IOMUX_VALUE); + rk29_mux_api_set(GPIO5A7_HSADCDATA2_NAME, GPIO5L_GPIO5A7); + return 0; +} + +static struct bu92747guw_platform_data bu92747guw_pdata = { + .intr_pin = BU92747_CIR_IRQ_PIN, + .iomux_init = cir_iomux_init, + .iomux_deinit = NULL, + .cir_pwr_ctl = bu92747guw_power_ctl, +}; +#endif +#ifdef CONFIG_RK29_NEWTON +struct rk29_newton_data rk29_newton_info = { +}; +struct platform_device rk29_device_newton = { + .name = "rk29_newton", + .id = -1, + .dev = { + .platform_data = &rk29_newton_info, + } + }; +#endif +#if defined (CONFIG_TOUCHSCREEN_FT5406) +#define TOUCH_RESET_PIN RK29_PIN6_PC3 +#define TOUCH_INT_PIN RK29_PIN0_PA2 +int ft5406_init_platform_hw(void) +{ + printk("ft5406_init_platform_hw\n"); + if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){ + gpio_free(TOUCH_RESET_PIN); + printk("ft5406_init_platform_hw gpio_request error\n"); + return -EIO; + } + + if(gpio_request(TOUCH_INT_PIN,NULL) != 0){ + gpio_free(TOUCH_INT_PIN); + printk("ift5406_init_platform_hw gpio_request error\n"); + return -EIO; + } + + gpio_direction_output(TOUCH_RESET_PIN, 0); + gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW); + mdelay(10); + gpio_direction_input(TOUCH_INT_PIN); + mdelay(10); + gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH); + msleep(300); + return 0; +} + +void ft5406_exit_platform_hw(void) +{ + printk("ft5406_exit_platform_hw\n"); + gpio_free(TOUCH_RESET_PIN); + gpio_free(TOUCH_INT_PIN); +} + +int ft5406_platform_sleep(void) +{ + printk("ft5406_platform_sleep\n"); + gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW); + return 0; +} + +int ft5406_platform_wakeup(void) +{ + printk("ft5406_platform_wakeup\n"); + gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH); + msleep(300); + return 0; +} + +struct ft5406_platform_data ft5406_info = { + + .init_platform_hw= ft5406_init_platform_hw, + .exit_platform_hw= ft5406_exit_platform_hw, + .platform_sleep = ft5406_platform_sleep, + .platform_wakeup = ft5406_platform_wakeup, + +}; +#endif + +#if defined(CONFIG_TOUCHSCREEN_GT819) +#define TOUCH_RESET_PIN RK29_PIN6_PC3 +#define TOUCH_INT_PIN RK29_PIN0_PA2 +int gt819_init_platform_hw(void) +{ + printk("gt819_init_platform_hw\n"); + if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){ + gpio_free(TOUCH_RESET_PIN); + printk("gt819_init_platform_hw gpio_request error\n"); + return -EIO; + } + + if(gpio_request(TOUCH_INT_PIN,NULL) != 0){ + gpio_free(TOUCH_INT_PIN); + printk("gt819_init_platform_hw gpio_request error\n"); + return -EIO; + } + gpio_direction_output(TOUCH_RESET_PIN, 0); + gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW); + mdelay(10); +// gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH); +// mdelay(10); +// gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW); + gpio_direction_input(TOUCH_INT_PIN); +// mdelay(10); + gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH); + msleep(300); + return 0; +} + + +void gt819_exit_platform_hw(void) +{ + printk("gt819_exit_platform_hw\n"); + gpio_free(TOUCH_RESET_PIN); + gpio_free(TOUCH_INT_PIN); +} + +int gt819_platform_sleep(void) +{ + printk("gt819_platform_sleep\n"); + gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW); + return 0; +} + +int gt819_platform_wakeup(void) +{ + printk("gt819_platform_wakeup\n"); + gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH); + //msleep(5); + //gpio_set_value(TOUCH_INT_PIN, GPIO_LOW); + //msleep(20); + //gpio_set_value(TOUCH_INT_PIN, GPIO_HIGH); + return 0; +} +struct goodix_platform_data goodix_info = { + + .init_platform_hw= gt819_init_platform_hw, + .exit_platform_hw= gt819_exit_platform_hw, + .platform_sleep = gt819_platform_sleep, + .platform_wakeup = gt819_platform_wakeup, + +}; +#endif + +/*goodix touch*/ +#if defined(CONFIG_TOUCHSCREEN_GT8XX) +#define TOUCH_RESET_PIN RK29_PIN6_PC3 +#define TOUCH_PWR_PIN RK29_PIN5_PA1 +int goodix_init_platform_hw(void) +{ + int ret; + printk("goodix_init_platform_hw\n"); + ret = gpio_request(TOUCH_PWR_PIN, "goodix power pin"); + if(ret != 0){ + gpio_free(TOUCH_PWR_PIN); + printk("goodix power error\n"); + return -EIO; + } + gpio_direction_output(TOUCH_PWR_PIN, 0); + gpio_set_value(TOUCH_PWR_PIN,GPIO_LOW); + msleep(100); + ret = gpio_request(TOUCH_RESET_PIN, "goodix reset pin"); + if(ret != 0){ + gpio_free(TOUCH_RESET_PIN); + printk("goodix gpio_request error\n"); + return -EIO; + } + gpio_direction_output(TOUCH_RESET_PIN, 0); + gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW); + msleep(10); + gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH); + msleep(500); + return 0; +} + +struct goodix_platform_data goodix_info = { + .model= 8105, + .irq_pin = RK29_PIN0_PA2, + .rest_pin = TOUCH_RESET_PIN, + .init_platform_hw = goodix_init_platform_hw, +}; +#endif + +#if defined (CONFIG_SND_SOC_CS42L52) + +int cs42l52_init_platform_hw() +{ + printk("cs42l52_init_platform_hw\n"); + if(gpio_request(RK29_PIN6_PB6,NULL) != 0){ + gpio_free(RK29_PIN6_PB6); + printk("cs42l52_init_platform_hw gpio_request error\n"); + return -EIO; + } + gpio_direction_output(RK29_PIN6_PB6, 0); + gpio_set_value(RK29_PIN6_PB6,GPIO_HIGH); + return 0; +} +struct cs42l52_platform_data cs42l52_info = { + + .init_platform_hw= cs42l52_init_platform_hw, + +}; +#endif +#if defined (CONFIG_BATTERY_BQ27541) +#define DC_CHECK_PIN RK29_PIN4_PA1 +#define LI_LION_BAT_NUM 1 +#define CHG_OK RK29_PIN4_PA3 +#define BAT_LOW RK29_PIN4_PA2 + +static int bq27541_init_dc_check_pin(void){ + if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){ + gpio_free(DC_CHECK_PIN); + printk("bq27541 init dc check pin request error\n"); + return -EIO; + } + gpio_direction_input(DC_CHECK_PIN); + return 0; +} + +struct bq27541_platform_data bq27541_info = { + .init_dc_check_pin = bq27541_init_dc_check_pin, + .dc_check_pin = DC_CHECK_PIN, + .bat_num = LI_LION_BAT_NUM, + .chgok_check_pin = CHG_OK, + .bat_check_pin = BAT_LOW, +}; +#endif +static struct android_pmem_platform_data android_pmem_pdata = { + .name = "pmem", + .start = PMEM_UI_BASE, + .size = PMEM_UI_SIZE, + .no_allocator = 1, + .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, + }, +}; + +#if PMEM_SKYPE_SIZE > 0 +static struct android_pmem_platform_data android_pmem_skype_pdata = { + .name = "pmem_skype", + .start = PMEM_SKYPE_BASE, + .size = PMEM_SKYPE_SIZE, + .no_allocator = 0, + .cached = 0, +}; + +static struct platform_device android_pmem_skype_device = { + .name = "android_pmem", + .id = 3, + .dev = { + .platform_data = &android_pmem_skype_pdata, + }, +}; +#endif + +#ifdef CONFIG_VIDEO_RK29XX_VOUT +static struct platform_device rk29_v4l2_output_devce = { + .name = "rk29_vout", +}; +#endif +/*HANNSTAR_P1003 touch*/ +#if defined (CONFIG_HANNSTAR_P1003) +#define TOUCH_RESET_PIN RK29_PIN6_PC3 +#define TOUCH_INT_PIN RK29_PIN0_PA2 + +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_EETI_EGALAX) +#define TOUCH_RESET_PIN RK29_PIN6_PC3 +#define TOUCH_INT_PIN RK29_PIN0_PA2 + +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, + .standby_pin = TOUCH_SCREEN_STANDBY_PIN, + .standby_value = TOUCH_SCREEN_STANDBY_VALUE, + .disp_on_pin = TOUCH_SCREEN_DISPLAY_PIN, + .disp_on_value = TOUCH_SCREEN_DISPLAY_VALUE, +}; +#endif + +#ifdef CONFIG_GS_KXTF9 +#include +#define KXTF9_DEVICE_MAP 1 +#define KXTF9_MAP_X (KXTF9_DEVICE_MAP-1)%2 +#define KXTF9_MAP_Y KXTF9_DEVICE_MAP%2 +#define KXTF9_NEG_X (KXTF9_DEVICE_MAP/2)%2 +#define KXTF9_NEG_Y (KXTF9_DEVICE_MAP+1)/4 +#define KXTF9_NEG_Z (KXTF9_DEVICE_MAP-1)/4 +struct kxtf9_platform_data kxtf9_pdata = { + .min_interval = 1, + .poll_interval = 20, + .g_range = KXTF9_G_2G, + .axis_map_x = KXTF9_MAP_X, + .axis_map_y = KXTF9_MAP_Y, + .axis_map_z = 2, + .negate_x = KXTF9_NEG_X, + .negate_y = KXTF9_NEG_Y, + .negate_z = KXTF9_NEG_Z, + //.ctrl_regc_init = KXTF9_G_2G | ODR50F, + //.ctrl_regb_init = ENABLE, +}; +#endif /* CONFIG_GS_KXTF9 */ + + +/*MMA8452 gsensor*/ +#if defined (CONFIG_GS_MMA8452) +#define MMA8452_INT_PIN RK29_PIN0_PA3 +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_xyz= 1, + .orientation ={-1,0,0,0,1,0,0,0,-1}, + .init_platform_hw= mma8452_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 }, + .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_PIN0_PA3, + .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 }, + }, +#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_PIN0_PA4, + .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_BATTERY_BQ27510) +#define DC_CHECK_PIN RK29_PIN4_PA1 +#define LI_LION_BAT_NUM 2 +static int bq27510_init_dc_check_pin(void){ + if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){ + gpio_free(DC_CHECK_PIN); + printk("bq27510 init dc check pin request error\n"); + return -EIO; + } + gpio_direction_input(DC_CHECK_PIN); + return 0; +} + +struct bq27510_platform_data bq27510_info = { + .init_dc_check_pin = bq27510_init_dc_check_pin, + .dc_check_pin = DC_CHECK_PIN, + .bat_num = LI_LION_BAT_NUM, +}; +#endif + +/*************************************PMU ACT8891****************************************/ + +#if defined (CONFIG_REGULATOR_ACT8891) + /*dcdc mode*/ +/*act8891 in REGULATOR_MODE_STANDBY mode is said DCDC is in PMF mode is can save power,when in REGULATOR_MODE_NORMAL +mode is said DCDC is in PWM mode , General default is in REGULATOR_MODE_STANDBY mode*/ + /*ldo mode */ +/*act8891 in REGULATOR_MODE_STANDBY mode is said LDO is in low power mode is can save power,when in REGULATOR_MODE_NORMAL +mode is said DCDC is in nomal mode , General default is in REGULATOR_MODE_STANDBY mode*/ +/*set dcdc and ldo voltage by regulator_set_voltage()*/ +static struct act8891 *act8891; +int act8891_set_init(struct act8891 *act8891) +{ + int tmp = 0; + struct regulator *act_ldo1,*act_ldo2,*act_ldo3,*act_ldo4; + struct regulator *act_dcdc1,*act_dcdc2,*act_dcdc3; + + /*init ldo1*/ + act_ldo1 = regulator_get(NULL, "act_ldo1"); + regulator_enable(act_ldo1); + regulator_set_voltage(act_ldo1,1800000,1800000); + tmp = regulator_get_voltage(act_ldo1); + regulator_set_mode(act_ldo1,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_ldo1,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: ldo1 vcc =%d\n",tmp); + regulator_put(act_ldo1); + + /*init ldo2*/ + act_ldo2 = regulator_get(NULL, "act_ldo2"); + regulator_enable(act_ldo2); + regulator_set_voltage(act_ldo2,1200000,1200000); + tmp = regulator_get_voltage(act_ldo2); + regulator_set_mode(act_ldo2,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_ldo2,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: ldo2 vcc =%d\n",tmp); + regulator_put(act_ldo2); + + /*init ldo3*/ + act_ldo3 = regulator_get(NULL, "act_ldo3"); + regulator_enable(act_ldo3); + regulator_set_voltage(act_ldo3,3300000,3300000); + tmp = regulator_get_voltage(act_ldo3); + regulator_set_mode(act_ldo3,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_ldo3,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: ldo3 vcc =%d\n",tmp); + regulator_put(act_ldo3); + + /*init ldo4*/ + act_ldo4 = regulator_get(NULL, "act_ldo4"); + regulator_enable(act_ldo4); + regulator_set_voltage(act_ldo4,2500000,2500000); + tmp = regulator_get_voltage(act_ldo4); + regulator_set_mode(act_ldo4,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_ldo4,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: ldo4 vcc =%d\n",tmp); + regulator_put(act_ldo4); + + /*init dcdc1*/ + act_dcdc1 = regulator_get(NULL, "act_dcdc1"); + regulator_enable(act_dcdc1); + regulator_set_voltage(act_dcdc1,3000000,3000000); + tmp = regulator_get_voltage(act_dcdc1); + regulator_set_mode(act_dcdc1,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_dcdc1,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: dcdc1 vcc =%d\n",tmp); + regulator_put(act_dcdc1); + + /*init dcdc2*/ + act_dcdc2 = regulator_get(NULL, "act_dcdc2"); + regulator_enable(act_dcdc2); + regulator_set_voltage(act_dcdc2,1500000,1500000); + tmp = regulator_get_voltage(act_dcdc2); + regulator_set_mode(act_dcdc2,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_dcdc2,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: dcdc2 vcc =%d\n",tmp); + regulator_put(act_dcdc2); + + /*init dcdc3*/ + act_dcdc3 = regulator_get(NULL, "act_dcdc3"); + regulator_enable(act_dcdc3); + regulator_set_voltage(act_dcdc3,1200000,1200000); + tmp = regulator_get_voltage(act_dcdc3); + regulator_set_mode(act_dcdc3,REGULATOR_MODE_STANDBY); + //regulator_set_mode(act_dcdc3,REGULATOR_MODE_NORMAL); + printk("***regulator_set_init: dcdc3 vcc =%d\n",tmp); + regulator_put(act_dcdc3); + + return(0); +} + +static struct regulator_consumer_supply act8891_ldo1_consumers[] = { + { + .supply = "act_ldo1", + } +}; + +static struct regulator_init_data act8891_ldo1_data = { + .constraints = { + .name = "ACT_LDO1", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_ldo1_consumers), + .consumer_supplies = act8891_ldo1_consumers, +}; + +/**/ +static struct regulator_consumer_supply act8891_ldo2_consumers[] = { + { + .supply = "act_ldo2", + } +}; + +static struct regulator_init_data act8891_ldo2_data = { + .constraints = { + .name = "ACT_LDO2", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_ldo2_consumers), + .consumer_supplies = act8891_ldo2_consumers, +}; + +/*ldo3 VCC_NAND WIFI/BT/FM_BCM4325*/ +static struct regulator_consumer_supply act8891_ldo3_consumers[] = { + { + .supply = "act_ldo3", + } +}; + +static struct regulator_init_data act8891_ldo3_data = { + .constraints = { + .name = "ACT_LDO3", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_ldo3_consumers), + .consumer_supplies = act8891_ldo3_consumers, +}; + +/*ldo4 VCCA CODEC_WM8994*/ +static struct regulator_consumer_supply act8891_ldo4_consumers[] = { + { + .supply = "act_ldo4", + } +}; + +static struct regulator_init_data act8891_ldo4_data = { + .constraints = { + .name = "ACT_LDO4", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_ldo4_consumers), + .consumer_supplies = act8891_ldo4_consumers, +}; +/*buck1 vcc Core*/ +static struct regulator_consumer_supply act8891_dcdc1_consumers[] = { + { + .supply = "act_dcdc1", + } +}; + +static struct regulator_init_data act8891_dcdc1_data = { + .constraints = { + .name = "ACT_DCDC1", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + //.always_on = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc1_consumers), + .consumer_supplies = act8891_dcdc1_consumers +}; + +/*buck2 VDDDR MobileDDR VCC*/ +static struct regulator_consumer_supply act8891_dcdc2_consumers[] = { + { + .supply = "act_dcdc2", + } +}; + +static struct regulator_init_data act8891_dcdc2_data = { + .constraints = { + .name = "ACT_DCDC2", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + //.always_on = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc2_consumers), + .consumer_supplies = act8891_dcdc2_consumers +}; + +/*buck3 vdd Core*/ +static struct regulator_consumer_supply act8891_dcdc3_consumers[] = { + { + .supply = "act_dcdc3", + } +}; + +static struct regulator_init_data act8891_dcdc3_data = { + .constraints = { + .name = "ACT_DCDC3", + .min_uV = 600000, + .max_uV = 3900000, + .apply_uV = 1, + //.always_on = 1, + .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE, + .valid_modes_mask = REGULATOR_MODE_STANDBY | REGULATOR_MODE_NORMAL, + }, + .num_consumer_supplies = ARRAY_SIZE(act8891_dcdc3_consumers), + .consumer_supplies = act8891_dcdc3_consumers +}; + +struct act8891_regulator_subdev act8891_regulator_subdev_id[] = { + { + .id=0, + .initdata=&act8891_ldo1_data, + }, + + { + .id=1, + .initdata=&act8891_ldo2_data, + }, + + { + .id=2, + .initdata=&act8891_ldo3_data, + }, + + { + .id=3, + .initdata=&act8891_ldo4_data, + }, + + { + .id=4, + .initdata=&act8891_dcdc1_data, + }, + + { + .id=5, + .initdata=&act8891_dcdc2_data, + }, + { + .id=6, + .initdata=&act8891_dcdc3_data, + }, + +}; + +struct act8891_platform_data act8891_data={ + .set_init=act8891_set_init, + .num_regulators=7, + .regulators=act8891_regulator_subdev_id, + +}; +#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_RT5621) + { + .type = "rt5621", + .addr = 0x1a, + .flags = 0, + }, +#endif +#if defined (CONFIG_SND_SOC_RT5631) + { + .type = "rt5631", + .addr = 0x1a, + .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_BATTERY_STC3100) + { + .type = "stc3100", + .addr = 0x70, + .flags = 0, + }, +#endif +#if defined (CONFIG_BATTERY_BQ27510) + { + .type = "bq27510", + .addr = 0x55, + .flags = 0, + .platform_data = &bq27510_info, + }, +#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_COMPASS_AK8973) + { + .type = "ak8973", + .addr = 0x1d, + .flags = 0, + .irq = RK29_PIN0_PA4, + }, +#endif +#if defined (CONFIG_COMPASS_AK8975) + { + .type = "ak8975", + .addr = 0x0d, + .flags = 0, + .irq = RK29_PIN0_PA4, + }, +#endif +/*mpu3050*/ +#if defined (CONFIG_MPU_SENSORS_MPU3050) + { + .type = "mpu3050", + .addr = 0x68, + .flags = 0, + .irq = RK29_PIN5_PA3, + .platform_data = &mpu3050_data, + }, +#endif +#if defined (CONFIG_SND_SOC_CS42L52) + { + .type = "cs42l52", + .addr = 0x4A, + .flags = 0, + .platform_data = &cs42l52_info, + }, +#endif +#if defined (CONFIG_RTC_M41T66) + { + .type = "rtc-M41T66", + .addr = 0x68, + .flags = 0, + .irq = RK29_PIN0_PA1, + }, +#endif +}; +#endif +#if defined (CONFIG_ANX7150) +struct hdmi_platform_data anx7150_data = { + //.io_init = anx7150_io_init, +}; +#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_ANX7150) + { + .type = "anx7150", + .addr = 0x39, //0x39, 0x3d + .flags = 0, + .irq = RK29_PIN1_PD7, + .platform_data = &anx7150_data, + }, +#endif +#ifdef CONFIG_BU92747GUW_CIR + { + .type ="bu92747_cir", + .addr = 0x77, + .flags =0, + .irq = BU92747_CIR_IRQ_PIN, + .platform_data = &bu92747guw_pdata, + }, +#endif + +}; +#endif + +#ifdef CONFIG_I2C2_RK29 +static struct i2c_board_info __initdata board_i2c2_devices[] = { +#if defined (CONFIG_HANNSTAR_P1003) + { + .type = "p1003_touch", + .addr = 0x04, + .flags = 0, //I2C_M_NEED_DELAY + .irq = RK29_PIN0_PA2, + .platform_data = &p1003_info, + //.udelay = 100 + }, +#endif +#if defined (CONFIG_EETI_EGALAX) + { + .type = "egalax_i2c", + .addr = 0x04, + .flags = 0, + .irq = RK29_PIN0_PA2, + .platform_data = &eeti_egalax_info, + }, +#endif +#if defined (CONFIG_TOUCHSCREEN_GT8XX) + { + .type = "Goodix-TS", + .addr = 0x55, + .flags =0, + .irq =RK29_PIN0_PA2, + .platform_data = &goodix_info, + }, +#endif +#if defined (CONFIG_TOUCHSCREEN_FT5406) + { + .type ="ft5x0x_ts", + .addr = 0x38, //0x70, + .flags =0, + .irq =RK29_PIN0_PA2, // support goodix tp detect, 20110706 + .platform_data = &ft5406_info, + }, +#endif +}; +#endif + +#ifdef CONFIG_I2C3_RK29 +static struct i2c_board_info __initdata board_i2c3_devices[] = { +#if defined (CONFIG_BATTERY_BQ27541) + { + .type = "bq27541", + .addr = 0x55, + .flags = 0, + .platform_data = &bq27541_info, + }, +#endif +#if defined (CONFIG_REGULATOR_ACT8891) + { + .type = "act8891", + .addr = 0x5b, + .flags = 0, + .platform_data=&act8891_data, + }, +#endif + +}; +#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 0 + +#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!!"; +} +#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_GPIO RK29_PIN1_PB5 +#define PWM_EFFECT_VALUE 0 + +#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 RK29_PIN6_PD0 +#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; +} + +static int rk29_backlight_pwm_suspend(void) +{ + int ret = 0; + rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO); + if (gpio_request(PWM_GPIO, NULL)) { + printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__); + return -1; + } + gpio_direction_output(PWM_GPIO, GPIO_LOW); + #ifdef LCD_DISP_ON_PIN + gpio_direction_output(BL_EN_PIN, 0); + gpio_set_value(BL_EN_PIN, !BL_EN_VALUE); + #endif + return ret; +} + +static int rk29_backlight_pwm_resume(void) +{ + gpio_free(PWM_GPIO); + rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE); + + #ifdef LCD_DISP_ON_PIN + msleep(30); + gpio_direction_output(BL_EN_PIN, 1); + gpio_set_value(BL_EN_PIN, BL_EN_VALUE); + #endif + return 0; +} + +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, + .pwm_suspend = rk29_backlight_pwm_suspend, + .pwm_resume = rk29_backlight_pwm_resume, +}; +#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 + +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) +#define SDMMC0_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin. +#endif + + +#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) +#define SDMMC1_WRITE_PROTECT_PIN RK29_PIN6_PB0 //According to your own project to set the value of write-protect-pin. +#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_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 + +#ifdef CONFIG_SDMMC0_RK29 +static int rk29_sdmmc0_cfg_gpio(void) +{ +#ifdef CONFIG_SDMMC_RK29_OLD + 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); + + rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2); + + rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5); + gpio_request(RK29_PIN5_PD5,"sdmmc"); +#if 0 + gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH); + mdelay(100); + gpio_set_value(RK29_PIN5_PD5,GPIO_LOW); +#else + gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW); +#endif + +#else + rk29_sdmmc_set_iomux(0, 0xFFFF); + + rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);//Modifyed by xbw. + + #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) + gpio_request(SDMMC0_WRITE_PROTECT_PIN,"sdmmc-wp"); + gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN); + #endif + +#endif + + 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, + +#if !defined(CONFIG_SDMMC_RK29_OLD) + .set_iomux = rk29_sdmmc_set_iomux, +#endif + + .dma_name = "sd_mmc", +#ifdef CONFIG_SDMMC0_USE_DMA + .use_dma = 1, +#else + .use_dma = 0, +#endif + .detect_irq = RK29_PIN2_PA2, // INVALID_GPIO + .enable_sd_wakeup = 0, + +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) + .write_prt = SDMMC0_WRITE_PROTECT_PIN, +#else + .write_prt = INVALID_GPIO, +#endif +}; +#endif +#ifdef CONFIG_SDMMC1_RK29 +#define CONFIG_SDMMC1_USE_DMA +static int rk29_sdmmc1_cfg_gpio(void) +{ +#if defined(CONFIG_SDMMC_RK29_OLD) + 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); + +#else + +#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + gpio_request(SDMMC1_WRITE_PROTECT_PIN,"sdio-wp"); + gpio_direction_input(SDMMC1_WRITE_PROTECT_PIN); +#endif + +#endif + + return 0; +} + + + +#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), + +#if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD) + .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_SDIO_IRQ| + MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED), +#else + .host_caps = (MMC_CAP_4_BIT_DATA|MMC_CAP_MMC_HIGHSPEED|MMC_CAP_SD_HIGHSPEED), +#endif + + .io_init = rk29_sdmmc1_cfg_gpio, + +#if !defined(CONFIG_SDMMC_RK29_OLD) + .set_iomux = rk29_sdmmc_set_iomux, +#endif + + .dma_name = "sdio", +#ifdef CONFIG_SDMMC1_USE_DMA + .use_dma = 1, +#else + .use_dma = 0, +#endif + +#if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD) +#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_SDMMC1_RK29_WRITE_PROTECT) + .write_prt = SDMMC1_WRITE_PROTECT_PIN, +#else + .write_prt = INVALID_GPIO, +#endif + +#else +//for wifi develop board + .detect_irq = INVALID_GPIO, + .enable_sd_wakeup = 0, +#endif + +}; +#endif ////endif--#ifdef CONFIG_SDMMC1_RK29 + + +int rk29sdk_wifi_power_state = 0; +int rk29sdk_bt_power_state = 0; + +#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_PC4 + +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; + +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); + + #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) + + rk29_mux_api_set(GPIO1C4_SDMMC1DATA1_NAME, GPIO1H_GPIO1C4); + gpio_request(RK29_PIN1_PC4, "mmc1-data1"); + gpio_direction_output(RK29_PIN1_PC4,GPIO_LOW);//set mmc1-data1 to low. + + rk29_mux_api_set(GPIO1C5_SDMMC1DATA2_NAME, GPIO1H_GPIO1C5); + gpio_request(RK29_PIN1_PC5, "mmc1-data2"); + gpio_direction_output(RK29_PIN1_PC5,GPIO_LOW);//set mmc1-data2 to low. + + rk29_mux_api_set(GPIO1C6_SDMMC1DATA3_NAME, GPIO1H_GPIO1C6); + gpio_request(RK29_PIN1_PC6, "mmc1-data3"); + gpio_direction_output(RK29_PIN1_PC6,GPIO_LOW);//set mmc1-data3 to low. + + rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13 + #endif + 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); + + #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) + rk29_sdmmc_gpio_open(1, 1); //added by xbw at 2011-10-13 + #endif + + 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); + + #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) + rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13 + #endif + + 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 +#define GPU_HIGH_CLOCK 552 +#define GPU_LOW_CLOCK (periph_pll_default / 1000000) /* same as general pll clock rate below */ +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, + }, + [3] = { + .name = "gpu_clk", + .start = GPU_LOW_CLOCK, + .end = GPU_HIGH_CLOCK, + .flags = IORESOURCE_IO, + }, +}; +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_LEDS_GPIO_PLATFORM +struct gpio_led rk29_leds[] = { + { + .name = "rk29_red_led", + .gpio = RK29_PIN4_PB2, + .default_trigger = "timer", + .active_low = 0, + .retain_state_suspended = 1, + .default_state = LEDS_GPIO_DEFSTATE_OFF, + }, + { + .name = "rk29_green_led", + .gpio = RK29_PIN4_PB1, + .default_trigger = "timer", + .active_low = 0, + .retain_state_suspended = 1, + .default_state = LEDS_GPIO_DEFSTATE_OFF, + }, + { + .name = "rk29_blue_led", + .gpio = RK29_PIN4_PB0, + .default_trigger = "timer", + .active_low = 0, + .retain_state_suspended = 1, + .default_state = LEDS_GPIO_DEFSTATE_OFF, + }, +}; + +struct gpio_led_platform_data rk29_leds_pdata = { + .leds = &rk29_leds, + .num_leds = ARRAY_SIZE(rk29_leds), +}; + +struct platform_device rk29_device_gpio_leds = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &rk29_leds_pdata, + }, +}; +#endif + +#ifdef CONFIG_LEDS_NEWTON_PWM +static struct led_newton_pwm rk29_pwm_leds[] = { + { + .name = "power_led", + .pwm_id = 1, + .pwm_gpio = RK29_PIN5_PD2, + .pwm_iomux_name = GPIO5D2_PWM1_UART1SIRIN_NAME, + .pwm_iomux_pwm = GPIO5H_PWM1, + .pwm_iomux_gpio = GPIO5H_GPIO5D2, + .freq = 1000, + .period = 255, + }, +}; + +static struct led_newton_pwm_platform_data rk29_pwm_leds_pdata = { + .leds = &rk29_pwm_leds, + .num_leds = ARRAY_SIZE(rk29_pwm_leds), +}; + +static struct platform_device rk29_device_pwm_leds = { + .name = "leds_newton_pwm", + .id = -1, + .dev = { + .platform_data = &rk29_pwm_leds_pdata, + }, +}; + +#endif +static void __init rk29_board_iomux_init(void) +{ + #ifdef CONFIG_RK29_PWM_REGULATOR + rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE); + #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_KEYS_RK29_NEWTON + &rk29_device_keys, +#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 + +#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_BACKLIGHT_RK29_NEWTON_BL + &rk29_device_backlight, +#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 +#if PMEM_SKYPE_SIZE > 0 + &android_pmem_skype_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, + &usb_mass_storage_device, +#endif +#ifdef CONFIG_USB_ANDROID_RNDIS + &rk29_device_rndis, +#endif +#ifdef CONFIG_RK29_IPP + &rk29_device_ipp, +#endif +#ifdef CONFIG_VIDEO_RK29XX_VOUT + &rk29_v4l2_output_devce, +#endif +#ifdef CONFIG_RK29_NEWTON + &rk29_device_newton, +#endif +#ifdef CONFIG_RK_IRDA + &irda_device, +#endif +#ifdef CONFIG_LEDS_GPIO_PLATFORM + &rk29_device_gpio_leds, +#endif +#ifdef CONFIG_LEDS_NEWTON_PWM + &rk29_device_pwm_leds, +#endif +#ifdef CONFIG_SND_RK29_SOC_CS42L52 + &rk29_cs42l52_device, +#endif +}; + +/***************************************************************************************** + * spi devices + * author: cmc@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, +}; + +/***************************************************************************************** + * 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= 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 struct cpufreq_frequency_table freq_table[] = { + { .index = 1200000, .frequency = 408000 }, + { .index = 1200000, .frequency = 816000 }, + { .index = 1300000, .frequency = 1008000 }, + { .frequency = CPUFREQ_TABLE_END }, +}; + +static void __init machine_rk29_board_init(void) +{ + rk29_board_iomux_init(); + + board_power_init(); + 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 + + board_usb_detect_init(RK29_PIN0_PA0); +#if defined(CONFIG_RK_IRDA) || defined(CONFIG_BU92747GUW_CIR) + smc0_init(NULL); + bu92747guw_io_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].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_init(periph_pll_default); + 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 diff --git a/arch/arm/mach-rk29/board-rk29-phonesdk.c b/arch/arm/mach-rk29/board-rk29-phonesdk.c index ac57fc82ef18..ee8dcbfa7a1f 100755 --- a/arch/arm/mach-rk29/board-rk29-phonesdk.c +++ b/arch/arm/mach-rk29/board-rk29-phonesdk.c @@ -51,8 +51,6 @@ #include #include #include -#include -#include #include #include @@ -79,7 +77,7 @@ #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h" #endif #include "../../../drivers/misc/gps/rk29_gps.h" -#include "../../../drivers/serial/sc8800.h" +#include "../../../drivers/tty/serial/sc8800.h" #ifdef CONFIG_VIDEO_RK29 /*---------------- Camera Sensor Macro Define Begin ------------------------*/ /*---------------- Camera Sensor Configuration Macro Begin ------------------------*/ @@ -160,6 +158,8 @@ #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]; @@ -712,9 +712,14 @@ int wm831x_pre_init(struct wm831x *parm) wm831x_reg_write(parm, WM831X_POWER_STATE, (ret&0xfff8) | 0x04); //BATT_FET_ENA = 1 - wm831x_set_bits(parm, WM831X_RESET_CONTROL,0x1000,0x1000); - ret = wm831x_reg_read(parm, WM831X_RESET_CONTROL) & 0xffff; - printk("%s:WM831X_RESET_CONTROL=0x%x\n",__FUNCTION__,ret); + 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 securit #if 0 wm831x_set_bits(parm, WM831X_LDO_ENABLE, (1 << 3), 0); @@ -1689,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 = { @@ -1928,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) @@ -2312,10 +2285,239 @@ struct platform_device rk2818_device_mtk23d = { }; #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) { @@ -2350,6 +2552,9 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = { .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 .enable_sd_wakeup = 0, @@ -2384,6 +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 @@ -3199,8 +3407,12 @@ static int rk29xx_virtual_keys_init(void) 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) @@ -3312,8 +3524,11 @@ static void __init machine_rk29_mapio(void) MACHINE_START(RK29, "RK29board") /* UART for LL DEBUG */ +#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, 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 index 000000000000..e5bc3145621a --- /dev/null +++ b/arch/arm/mach-rk29/board-rk29-td8801_v2-key.c @@ -0,0 +1,105 @@ +#include +#include + +#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 index 000000000000..d5a5d01e1aa0 --- /dev/null +++ b/arch/arm/mach-rk29/board-rk29-td8801_v2-rfkill.c @@ -0,0 +1,313 @@ +/* + * Copyright (C) 2010 ROCKCHIP, Inc. + * Author: roger_chen + * + * This program is the bluetooth device bcm4329's driver, + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 index 000000000000..cd62c6c24441 --- /dev/null +++ b/arch/arm/mach-rk29/board-rk29-td8801_v2.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include /* ddl@rock-chips.com : camera support */ +#include /* ddl@rock-chips.com : camera support */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "devices.h" + + +#if defined(CONFIG_TDSC8800) +#include +#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;igpio_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<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< +#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 = >801_info, +}, +#endif + +#if defined (CONFIG_TOUCHSCREEN_GT818_IIC) +{ + .type = "gt818_ts", + .addr = 0x5d, + .flags = 0, + .irq = RK29_PIN4_PD5, + .platform_data = >818_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= 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 diff --git a/arch/arm/mach-rk29/board-rk29k97-key.c b/arch/arm/mach-rk29/board-rk29k97-key.c new file mode 100755 index 000000000000..51c7c5722f67 --- /dev/null +++ b/arch/arm/mach-rk29/board-rk29k97-key.c @@ -0,0 +1,108 @@ +#include +#include +#include + +#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_PA4, + .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 = "esc", + .code = KEY_BACK, + .gpio = RK29_PIN6_PA0, + .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, + //.code_long_press = EV_ENCALL, + .wakeup = 1, + }, +#if 0 + { + .desc = "vol+", + .code = KEY_VOLUMEDOWN, + .adc_value = 95, + .gpio = INVALID_GPIO, + .active_low = PRESS_LEV_LOW, + }, + { + .desc = "vol-", + .code = KEY_VOLUMEUP, + .adc_value = 249, + .gpio = INVALID_GPIO, + .active_low = PRESS_LEV_LOW, + }, + { + .desc = "menu", + .code = EV_MENU, + .adc_value = 406, + .gpio = INVALID_GPIO, + .active_low = PRESS_LEV_LOW, + }, + { + .desc = "home", + .code = KEY_HOME, + .code_long_press = KEY_F4, + .adc_value = 561, + .gpio = INVALID_GPIO, + .active_low = PRESS_LEV_LOW, + }, + { + .desc = "esc", + .code = KEY_ESC, + .adc_value = 726, + .gpio = INVALID_GPIO, + .active_low = PRESS_LEV_LOW, + }, + { + .desc = "adkey6", + .code = KEY_BACK, + .code_long_press = EV_ENCALL, + .adc_value = 899, + .gpio = INVALID_GPIO, + .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/ddr.c b/arch/arm/mach-rk29/ddr.c index 181c02e4cad1..308897e4c306 100755 --- a/arch/arm/mach-rk29/ddr.c +++ b/arch/arm/mach-rk29/ddr.c @@ -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 */ @@ -261,6 +266,7 @@ #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) -{ - uint32_t count; - if(cpu_freq == 24) - count = us * 6;//533; - else - count = us*200; - while(count--) // 3 cycles - barrier(); +static __sramdata uint32_t loops_per_us; +#define LPJ_100MHZ 499728UL + +/*static*/ void __sramlocalfunc delayus(uint32_t us) +{ + 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; + uint32_t regvalue = pSCU_Reg->CRU_APLL_CON; + uint32_t freq; - if((pSCU_Reg->CRU_MODE_CON & 0x03) == 0x03) - cpu_freq = 24; - else - cpu_freq = clk_get_rate(clk_get(NULL,"core"))/1000000; + // 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 diff --git a/arch/arm/mach-rk29/devices.c b/arch/arm/mach-rk29/devices.c index 0f49e6c8cb38..264a63736816 100644 --- a/arch/arm/mach-rk29/devices.c +++ b/arch/arm/mach-rk29/devices.c @@ -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[] = { diff --git a/arch/arm/mach-rk29/devices.h b/arch/arm/mach-rk29/devices.h index b6d2d16d5927..1a3eefa72ebb 100644 --- a/arch/arm/mach-rk29/devices.h +++ b/arch/arm/mach-rk29/devices.h @@ -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; diff --git a/arch/arm/mach-rk29/include/mach/board.h b/arch/arm/mach-rk29/include/mach/board.h index d56c42310dba..d9c9068afcaf 100755 --- a/arch/arm/mach-rk29/include/mach/board.h +++ b/arch/arm/mach-rk29/include/mach/board.h @@ -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; @@ -274,6 +285,9 @@ struct ft5406_platform_data { }; struct goodix_platform_data { + int model ; + int rest_pin; + int irq_pin ; int (*get_pendown_state)(void); int (*init_platform_hw)(void); int (*platform_sleep)(void); diff --git a/arch/arm/mach-rk29/include/mach/rk29_camera.h b/arch/arm/mach-rk29/include/mach/rk29_camera.h index b921507ff684..855e2396fee4 100755 --- a/arch/arm/mach-rk29/include/mach/rk29_camera.h +++ b/arch/arm/mach-rk29/include/mach/rk29_camera.h @@ -160,6 +160,7 @@ struct rk29camera_gpio_res { unsigned int gpio_flash; unsigned int gpio_flag; unsigned int gpio_init; + unsigned int orientation; const char *dev_name; }; diff --git a/arch/arm/mach-rk29/pm.c b/arch/arm/mach-rk29/pm.c index a9314741a701..9511c7daa848 100755 --- a/arch/arm/mach-rk29/pm.c +++ b/arch/arm/mach-rk29/pm.c @@ -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 diff --git a/arch/arm/mach-rk29/spi_sram.c b/arch/arm/mach-rk29/spi_sram.c index 7e49d6ee3e0a..56760c7d8484 100755 --- a/arch/arm/mach-rk29/spi_sram.c +++ b/arch/arm/mach-rk29/spi_sram.c @@ -7,7 +7,21 @@ #include #include +#include +#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; diff --git a/drivers/cmmb/cmmb_class.h b/drivers/cmmb/cmmb_class.h index 3294f55ff520..d6e9e5a48fd8 100755 --- a/drivers/cmmb/cmmb_class.h +++ b/drivers/cmmb/cmmb_class.h @@ -6,7 +6,6 @@ #include #include #include -#include #define CMMB_MAJOR 200 @@ -54,4 +53,4 @@ void cmmb_unregister_device(struct cmmb_device *cmmbdev); FUNCTION(ARGS); \ -#endif/* #ifndef _CMMB_CLASS_H_ */ \ No newline at end of file +#endif/* #ifndef _CMMB_CLASS_H_ */ diff --git a/drivers/cmmb/cmmb_memory.c b/drivers/cmmb/cmmb_memory.c index ca8c2005aa89..0e8c03d26798 100755 --- a/drivers/cmmb/cmmb_memory.c +++ b/drivers/cmmb/cmmb_memory.c @@ -4,6 +4,8 @@ #include #include #include +#include + #if 1 #define DBGERR(x...) printk(KERN_INFO x) #else diff --git a/drivers/cmmb/siano/smscoreapi.c b/drivers/cmmb/siano/smscoreapi.c index 52d8bc278896..79a09e98283d 100755 --- a/drivers/cmmb/siano/smscoreapi.c +++ b/drivers/cmmb/siano/smscoreapi.c @@ -37,6 +37,7 @@ #include "smsendian.h" #include "sms-cards.h" #include +#include #define MAX_GPIO_PIN_NUMBER 31 diff --git a/drivers/cmmb/siano/smsspiphy.h b/drivers/cmmb/siano/smsspiphy.h index 392a6ed64f0a..086292ce7abf 100755 --- a/drivers/cmmb/siano/smsspiphy.h +++ b/drivers/cmmb/siano/smsspiphy.h @@ -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__ */ diff --git a/drivers/headset_observe/rk_headset.c b/drivers/headset_observe/rk_headset.c index ad99920e5e90..e5b6f6d178ac 100755 --- a/drivers/headset_observe/rk_headset.c +++ b/drivers/headset_observe/rk_headset.c @@ -39,6 +39,7 @@ #include #include #include +#include /* Debug */ #if 1 @@ -60,8 +61,11 @@ #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; @@ -258,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); @@ -325,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"); @@ -333,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); diff --git a/drivers/input/gsensor/Kconfig b/drivers/input/gsensor/Kconfig index efb19a016b38..30cda547ea2f 100755 --- a/drivers/input/gsensor/Kconfig +++ b/drivers/input/gsensor/Kconfig @@ -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 diff --git a/drivers/input/gsensor/Makefile b/drivers/input/gsensor/Makefile index 2f7f9c0ad14c..f1bdebf8c1f8 100755 --- a/drivers/input/gsensor/Makefile +++ b/drivers/input/gsensor/Makefile @@ -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 index 000000000000..d4d66cb0301c --- /dev/null +++ b/drivers/input/gsensor/bma023.c @@ -0,0 +1,920 @@ +/* drivers/i2c/chips/bma023.c - bma023 compass driver + * + * Copyright (C) 2007-2008 HTC Corporation. + * Author: Hou-Kun Chen + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#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<>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 "); +MODULE_DESCRIPTION("BMA150 driver"); +MODULE_LICENSE("GPL"); + +module_init(BMA150_init); +module_exit(BMA150_exit); diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 46651a249695..1a362c11bf68 100755 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -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 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index d17fcab89d61..3b6e7b0e262b 100755 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -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 index 000000000000..e11291b0bf2f --- /dev/null +++ b/drivers/input/misc/al3006.c @@ -0,0 +1,833 @@ +/* drivers/input/misc/al3006.c + * + * Copyright (C) 2010 ROCK-CHIPS, Inc. + * Author: eric + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "al3006.h" + +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif + +#include +#include + +#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 *)® + 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] && valueclient; + + 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 index 000000000000..30e084c64634 --- /dev/null +++ b/drivers/input/misc/al3006.h @@ -0,0 +1,33 @@ +/* include/linux/isl29028.h + * + * Copyright (C) 2009 Google, Inc. + * Author: Iliyan Malchev + * + * 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 +#include + +#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 diff --git a/drivers/input/misc/isl29028.c b/drivers/input/misc/isl29028.c index 18fa05d3dfc9..055f53c5a4b1 100755 --- a/drivers/input/misc/isl29028.c +++ b/drivers/input/misc/isl29028.c @@ -27,6 +27,7 @@ #include #include #include "isl29028.h" +#include #ifdef CONFIG_HAS_EARLYSUSPEND #include diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 846f9603f0ca..212a2a3e6a1a 100755 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -115,6 +115,13 @@ config TOUCHSCREEN_ILI2102_IIC code includes that in its table of IIC devices. If unsure, say N (but it's safe to say "Y"). +config TOUCHSCREEN_GT8XX + tristate "Goodix touch screen gt8xx support for rk29" + help + Say Y here if you have a touchscreen interface using the + goodix gt8xx , and your board-specific initialization + code includes that in its table of IIC devices. + If unsure, say N (but it's safe to say "Y"). config RK28_I2C_TS_NTP070 tristate "NTP070 based touchscreens: NTP070 Interface" @@ -954,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 diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 6bd028a9ffcb..94e802ad900f 100755 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -78,7 +78,9 @@ obj-$(CONFIG_TOUCHSCREEN_GT801_IIC) += gt801_ts.o obj-$(CONFIG_TOUCHSCREEN_GT818_IIC) += gt818_ts.o obj-$(CONFIG_TOUCHSCREEN_ILI2102_IIC) += ili2102_ts.o obj-$(CONFIG_D70_L3188A) += goodix_touch.o +obj-$(CONFIG_TOUCHSCREEN_GT8XX) += rk29_i2c_goodix.o 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 diff --git a/drivers/input/touchscreen/eeti_egalax_i2c.c b/drivers/input/touchscreen/eeti_egalax_i2c.c index ee5624b39cd7..af0c5f0ed8e4 100755 --- a/drivers/input/touchscreen/eeti_egalax_i2c.c +++ b/drivers/input/touchscreen/eeti_egalax_i2c.c @@ -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; diff --git a/drivers/input/touchscreen/gt818_ts.c b/drivers/input/touchscreen/gt818_ts.c index 6e55be7fba17..8dd6b5d20f94 100644 --- a/drivers/input/touchscreen/gt818_ts.c +++ b/drivers/input/touchscreen/gt818_ts.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "gt818_ts.h" @@ -76,6 +77,9 @@ static void goodix_ts_late_resume(struct early_suspend *h); #define MAX_KEY_NUM (sizeof(gt818_key_array)/sizeof(gt818_key_array[0])) #endif +unsigned int last_x[MAX_FINGER_NUM + 1]= {0}; +unsigned int last_y[MAX_FINGER_NUM + 1]= {0}; + /*Function as i2c_master_send */ static int i2c_read_bytes(struct i2c_client *client, u8 *buf, int len) @@ -303,19 +307,23 @@ static void goodix_ts_work_func(struct work_struct *work) for(position = 1; position < MAX_FINGER_NUM + 1; position++) { - //printk("%s:positon:%d\n", __func__, position); if((finger_current[position] == 0) && (finger_last[position] != 0)) { - input_report_abs(ts->input_dev, ABS_MT_POSITION_X, 0); - input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, 0); - input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); - input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); - input_mt_sync(ts->input_dev); + //printk("<<<<<<<<<<<<<<<<<<<%s:positon:%d (%d,%d)\n", __func__, position,last_x,last_y); + //printk("<<<%d , %d ",finger_current[position],finger_last[position]); + //input_mt_slot(ts->input_dev, position); + //input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); + //input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); + //input_report_abs(ts->input_dev, ABS_MT_POSITION_X, last_x[position]); + //input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, last_y[position]); + //input_report_abs(ts->input_dev, ABS_MT_PRESSURE, 100); + //input_mt_sync(ts->input_dev); + input_mt_slot(ts->input_dev, position); + input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false); syn_flag = 1; } else if(finger_current[position]) { - x = (*(coor_point+3*(position-1)))*SCREEN_MAX_WIDTH/(TOUCH_MAX_WIDTH); y = (*(coor_point+3*(position-1)+1))*SCREEN_MAX_HEIGHT/(TOUCH_MAX_HEIGHT); pressure = (*(coor_point+3*(position-1)+2)); @@ -326,15 +334,25 @@ static void goodix_ts_work_func(struct work_struct *work) if(y < SCREEN_MAX_HEIGHT){ // y = SCREEN_MAX_HEIGHT-y; } - input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, position - 1); + + //printk(">>>>>>>>>>>>>>>>>%s:positon:%d (%d,%d)\n", __func__, position,x,y); + input_mt_slot(ts->input_dev, position); + input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 1); + input_report_abs(ts->input_dev, ABS_MT_PRESSURE, pressure); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, x); input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, y); - input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, pressure); - input_mt_sync(ts->input_dev); + + last_x[position] = x; + last_y[position] = y; + //input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, pressure); + //input_mt_sync(ts->input_dev); syn_flag = 1; } - } + +} +input_sync(ts->input_dev); + #ifdef HAVE_TOUCH_KEY @@ -488,7 +506,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id struct gt818_ts_data *ts; struct gt818_platform_data *pdata; - dev_dbg(&client->dev,"Install touch driver.\n"); + dev_info(&client->dev,"Install touch driver.\n"); printk("gt818: Install touch driver.\n"); //Check I2C function if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) @@ -576,10 +594,10 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id goto err_input_dev_alloc_failed; } - ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; - ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); - ts->input_dev->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 + //ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ; + //ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); + //ts->input_dev->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 #ifdef HAVE_TOUCH_KEY @@ -600,13 +618,16 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id ts->input_dev->id.product = 0xBEEF; ts->input_dev->id.version = 10427; //screen firmware version + __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); + __set_bit(EV_ABS, ts->input_dev->evbit); #ifdef GOODIX_MULTI_TOUCH - - input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); + input_mt_init_slots(ts->input_dev, MAX_FINGER_NUM); + //input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, SCREEN_MAX_WIDTH, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_HEIGHT, 0, 0); - input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MAX_FINGER_NUM, 0, 0); + //input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MAX_FINGER_NUM, 0, 0); + input_set_abs_params(ts->input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0); #else input_set_abs_params(ts->input_dev, ABS_X, 0, SCREEN_MAX_HEIGHT, 0, 0); input_set_abs_params(ts->input_dev, ABS_Y, 0, SCREEN_MAX_WIDTH, 0, 0); @@ -619,7 +640,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id goto err_input_register_device_failed; } ts->bad_data = 0; -// finger_list.length = 0; +// 16finger_list.length = 0; client->irq = gpio_to_irq(pdata->gpio_pendown); //If not defined in client if (client->irq) @@ -834,6 +855,6 @@ late_initcall(goodix_ts_init); module_exit(goodix_ts_exit); MODULE_DESCRIPTION("Goodix Touchscreen Driver"); -MODULE_AUTHOR("hhb@rock-chips.com") +MODULE_AUTHOR("hhb@rock-chips.com"); MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/ili2102_ts.c b/drivers/input/touchscreen/ili2102_ts.c index d95e9bc22c00..ff3775d646be 100755 --- a/drivers/input/touchscreen/ili2102_ts.c +++ b/drivers/input/touchscreen/ili2102_ts.c @@ -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 index 000000000000..cdd5c83f34a8 --- /dev/null +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#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 "); +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 index 000000000000..e19773eee24b --- /dev/null +++ b/drivers/input/touchscreen/pixcir_i2c_ts.h @@ -0,0 +1,74 @@ +#ifndef __DRIVERS_TOUCHSCREEN_PIXCIR_TS_H +#define __DRIVERS_TOUCHSCREEN_PIXCIR_TS_H + +// #include + +static int attb_read_val(void); +static void tangoC_init(void); + +#define X_MAX 480 +#define Y_MAX 800 +#define MAX_SUPPORT_POINT 5 + +#define IOMUX_NAME_SIZE 48 +struct pixcir_platform_data { + + u16 model; /*. */ + bool swap_xy; /* swap x and y axes */ + u16 x_min, x_max; + u16 y_min, y_max; + int gpio_reset; + int gpio_reset_active_low; + int gpio_pendown; /* the GPIO used to decide the pendown */ + + char pendown_iomux_name[IOMUX_NAME_SIZE]; + char resetpin_iomux_name[IOMUX_NAME_SIZE]; + int pendown_iomux_mode; + int resetpin_iomux_mode; + + uint8_t virtual_key_num; + uint16_t virtual_key_code[4]; + + int (*get_pendown_state)(void); +}; + +//Platform gpio define +//#define S5PC1XX + +#ifdef S5PC1XX + #include //reset pin GPE1_5 + #include //attb pin GPH1_3 + #include + #include + + #define ATTB S5PC1XX_GPH1(3) + #define get_attb_value gpio_get_value + #define RESETPIN_CFG s3c_gpio_cfgpin(S5PC1XX_GPE1(5),S3C_GPIO_OUTPUT) + #define RESETPIN_SET0 gpio_direction_output(S5PC1XX_GPE1(5),0) + #define RESETPIN_SET1 gpio_direction_output(S5PC1XX_GPE1(5),1) + +#else //mini6410 + +// #include +// #include +// #include +// #include + + #define ATTB RK29_PIN4_PD5 + #define get_attb_value gpio_get_value + #define RESETPIN_CFG //s3c_gpio_cfgpin(RK29_PIN4_PD5,S3C_GPIO_OUTPUT) + //rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO); + #define RESETPIN_SET0 gpio_direction_output(RK29_PIN4_PD5,0) + #define RESETPIN_SET1 gpio_direction_output(RK29_PIN4_PD5,1) +#endif + +static int attb_read_val(void) +{ + return gpio_get_value(RK29_PIN4_PD5); +} + +/*static void tangoC_init(void) +{ + RESETPIN_SET0; +}*/ +#endif diff --git a/drivers/input/touchscreen/rk29_i2c_goodix.c b/drivers/input/touchscreen/rk29_i2c_goodix.c new file mode 100755 index 000000000000..e59a413ec8bc --- /dev/null +++ b/drivers/input/touchscreen/rk29_i2c_goodix.c @@ -0,0 +1,1651 @@ +/* drivers/input/touchscreen/goodix_touch.c + * + * Copyright (C) 2010 - 2011 Goodix, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +//#include +//#include +//#include +#include +#include +#include +#include +#include "rk29_i2c_goodix.h" +//#include + +#include +#include +#include +#include +#include +#include + +#define PEN_DOWN 1 +#define PEN_RELEASE 0 +#define MAX_SUPPORT_POINT 2 +//#define fjp_debug 0 + +//#define fjp_debug +/******************************************************* +Description: + Read data from the i2c slave device; + This operation consisted of 2 i2c_msgs,the first msg used + to write the operate address,the second msg used to read data. + +Parameter: + client: i2c device. + buf[0]:operate address. + buf[1]~buf[len]:read data buffer. + len:operate length. + +return: + numbers of i2c_msgs to transfer +*********************************************************/ +static int goodix_i2c_read_bytes(struct i2c_client *client, uint8_t *buf, int len) +{ + struct i2c_msg msgs[2]; + int ret=-1; + int retries = 0; + + msgs[0].flags = client->flags; + msgs[0].addr=client->addr; + msgs[0].len=1; + msgs[0].buf=&buf[0]; + msgs[0].udelay = client->udelay; + msgs[0].scl_rate=200 * 1000; + + msgs[1].flags = client->flags | I2C_M_RD; + msgs[1].addr=client->addr; + msgs[1].len=len-1; + msgs[1].buf=&buf[1]; + msgs[1].udelay = client->udelay; + msgs[1].scl_rate=200 * 1000; + + //disable_irq(client->irq); + while(retries<5) + { + ret=i2c_transfer(client->adapter,msgs, 2); + if(ret == 2)break; + retries++; + } + //enable_irq(client->irq); + return ret; +} + +/******************************************************* +Description: + write data to the i2c slave device. + +Parameter: + client: i2c device. + buf[0]:operate address. + buf[1]~buf[len]:write data buffer. + len:operate length. + +return: + numbers of i2c_msgs to transfer. +*********************************************************/ +static int goodix_i2c_write_bytes(struct i2c_client *client,uint8_t *data,int len) +{ + struct i2c_msg msg; + int ret=-1; + int retries = 0; + + msg.flags=!I2C_M_RD; + msg.addr=client->addr; + msg.len=len; + msg.buf=data; + msg.udelay = client->udelay; + msg.scl_rate=200 * 1000; + + //disable_irq(client->irq); + while(retries<5) + { + ret=i2c_transfer(client->adapter,&msg, 1); + if(ret == 1)break; + retries++; + } + //enable_irq(client->irq); + return ret; +} + +/******************************************************* +Description: + Goodix touchscreen initialize function. + +Parameter: + ts: i2c client private struct. + +return: + Executive outcomes.0---succeed. +*******************************************************/ +static int goodix_init_panel(struct rk_ts_data *ts) +{ + int ret=-1; + uint8_t rd_cfg_buf[7] = {0x66,}; + +#ifdef GOODIX_1024X768 //for malata 10.1 + uint8_t config_info[] = { + 0x65,0x02,0x04,0x00,0x03,0x00,0x0A,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C, + 0x41,0x41,0x20,0x09,0x00,0xA0,0xA0,0x3C,0x64,0x0E,0x0D,0x0C,0x0B,0x0A,0x09, + 0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C,0x1B,0x1A,0x19,0x18, + 0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + }; + /* uint8_t config_info[] = { + 0x65,0x02,0x04,0x00,0x03,0x00,0x0a,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C, + 0x40,0x41,0x20,0x00,0x00,0x8B,0x8B,0x3C,0x64,0x0E,0x0D,0x0C,0x0B, + 0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C, + 0x1B,0x1A,0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 + }; */ +#else + /*uint8_t config_info[] = { + 0x65,0x02,0x05,0x00,0x03,0x20,0x05,0x20,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C, + 0x40,0x41,0x20,0x00,0x00,0x89,0x89,0x5A,0x96,0x0E,0x0D,0x0C,0x0B,0x0A,0x09, + 0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C,0x1B,0x1A,0x19,0x18, + 0x17,0x15,0x15,0x14,0x13,0x12,0x11,0x10,0x0F,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x00 + };*/ + uint8_t config_info[] = { + 0x65,0x02,0x05,0x00,0x03,0x20,0x0A,0x22,0x1E,0xE7,0x32,0x05,0x08,0x10,0x4C, + 0x42,0x42,0x20,0x00,0x00,0x89,0x89,0x3C,0x64,0x0E,0x0D,0x0C,0x0B, + 0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x1D,0x1C, + 0x1B,0x1A,0x19,0x18,0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x2B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 + }; +#endif + ret=goodix_i2c_write_bytes(ts->client,config_info, (sizeof(config_info)/sizeof(config_info[0]))); + if (ret < 0) { + printk("goodix write cfg info err"); + return ret; + } + ret=goodix_i2c_read_bytes(ts->client, rd_cfg_buf, 7); + if(ret != 2) + { + dev_info(&ts->client->dev, "Read resolution & max_touch_num failed, use default value!\n"); + ts->max_touch_num = MAX_FINGER_NUM; + ts->int_trigger_type = INT_TRIGGER; + return 0; + } + ts->abs_x_max = (rd_cfg_buf[1]<<8) + rd_cfg_buf[2]; + ts->abs_y_max = (rd_cfg_buf[3]<<8) + rd_cfg_buf[4]; + ts->max_touch_num = rd_cfg_buf[5]; + ts->int_trigger_type = rd_cfg_buf[6]&0x03; + if((!ts->abs_x_max)||(!ts->abs_y_max)||(!ts->max_touch_num)) + { + printk(KERN_INFO "Read invalid resolution & max_touch_num, use default value!\n"); + ts->max_touch_num = MAX_FINGER_NUM; + } + + printk(KERN_INFO "X_MAX = %d,Y_MAX = %d,MAX_TOUCH_NUM = %d\n",ts->abs_x_max,ts->abs_y_max,ts->max_touch_num); + printk(KERN_INFO "int_trigger type is %d\n",rd_cfg_buf[6]); + //test + rd_cfg_buf[0] = 0x6e; + rd_cfg_buf[1] = 0x00; + goodix_i2c_read_bytes(ts->client, rd_cfg_buf, 2); + if((rd_cfg_buf[1]&0x0f)==0x0f) + { + dev_info(&ts->client->dev, "Need int wake up from green mode!\n"); + } + + //msleep(10); + printk("max_point:%d\n",ts->max_touch_num); + return 0; + +} + +/******************************************************* +Description: + Read goodix touchscreen version function. + +Parameter: + ts: i2c client private struct. + +return: + Executive outcomes.0---succeed. +*******************************************************/ +static int goodix_read_version(struct rk_ts_data *ts, char **version) +{ + int ret = -1, count = 0; + char *version_data; + char *p; + + *version = (char *)vmalloc(18); + version_data = *version; + if(!version_data) + return -ENOMEM; + p = version_data; + memset(version_data, 0, sizeof(version_data)); + version_data[0]=240; + ret=goodix_i2c_read_bytes(ts->client,version_data, 17); + if (ret < 0) + return ret; + version_data[17]='\0'; + + if(*p == '\0') + return 0; + do + { + if((*p > 122) || (*p < 48 && *p != 32) || (*p >57 && *p < 65) + ||(*p > 90 && *p < 97 && *p != '_')) //check illeqal character + count++; + }while(*++p != '\0' ); + if(count > 2) + return 0; + else + return 1; +} + +static last_touch_num = -1; +static void goodix_get_touch_info(struct rk_ts_data *ts,char *point_num,struct rk_touch_info* info_buf) +{ + uint8_t point_data[(1-READ_COOR_ADDR)+1+2+5*MAX_FINGER_NUM+1]={ 0 }; //read address(1byte)+key index(1byte)+point mask(2bytes)+5bytes*MAX_FINGER_NUM+coor checksum(1byte) + uint8_t check_sum = 0; + int ret ; + uint16_t finger_current = 0; + uint16_t finger_bit = 0; + unsigned int count = 0, point_count = 0; + unsigned char touch_num = 0; + uint8_t chksum_err = 0; + unsigned int position = 0; + uint8_t track_id[MAX_FINGER_NUM] = {0}; + u8 index; + + point_data[0] = READ_COOR_ADDR; //read coor address + + + ret=goodix_i2c_read_bytes(ts->client, point_data, sizeof(point_data)/sizeof(point_data[0])); + if(ret != 2) + { + printk("goodix read error\n"); + ts->bad_data = 1; + } + finger_current = (point_data[3 - READ_COOR_ADDR]<<8) + point_data[2 - READ_COOR_ADDR]; + #ifdef fjp_debug + printk("finger_current:%d ==== max_touch_num:%d\n", finger_current,ts->max_touch_num);//add by fjp 2010-9-28 + #endif + + if(finger_current) + { + point_count = 0; + finger_bit = finger_current; + for(count = 0; (finger_bit != 0) && (count < ts->max_touch_num); count++)//cal how many point touch currntly + { + if(finger_bit & 0x01) + { + track_id[point_count] = count; + point_count++; + } + finger_bit >>= 1; + } + touch_num = point_count; + + check_sum = point_data[2 - READ_COOR_ADDR] + point_data[3 - READ_COOR_ADDR]; //cal coor checksum + count = 4 - READ_COOR_ADDR; + for(point_count *= 5; point_count > 0; point_count--) + check_sum += point_data[count++]; + check_sum += point_data[count]; + if(check_sum != 0) //checksum verify error + { + printk("coor checksum error!\n"); + } + else + { + chksum_err = 0; + } + } + + //printk("current point num:%d\n",touch_num); + *point_num = touch_num; + if(touch_num < last_touch_num) //some flinger release + { + //printk("%d flinger release\n",last_touch_num-touch_num); + for(index = touch_num; index < last_touch_num; index++) + info_buf[index].status = 0; + *point_num = last_touch_num; + } + last_touch_num = touch_num; + for(index = 0; index < touch_num; index++) + { + position = 4 - READ_COOR_ADDR + 5*index; + info_buf[index].x = (unsigned int) (point_data[position]<<8) + (unsigned int)( point_data[position+1]); + info_buf[index].y = (unsigned int)(point_data[position+2]<<8) + (unsigned int) (point_data[position+3]); + info_buf[index].status = !gpio_get_value(ts->irq_pin); + } + +} + + +/******************************************************* +Description: + Goodix touchscreen work function. + +Parameter: + ts: i2c client private struct. + +return: + Executive outcomes.0---succeed. +*******************************************************/ +static int rk_ts_work_func(struct work_struct *pwork) +{ + int i =0; + struct rk_touch_info *info_buf; + char point_num; + + if(pwork==NULL) + { + printk(KERN_INFO "%s>>>>>>>>err:null pwork\n",__func__); + return -1; + } + + struct rk_ts_data *ts = container_of(pwork, struct rk_ts_data, ts_work); + if(!ts) + { + printk("container of rk_ts_data fail\n"); + return -1; + } + + info_buf= kzalloc(ts->max_touch_num*sizeof(struct rk_touch_info), GFP_KERNEL); + if(!info_buf) + { + printk(KERN_ALERT "alloc for rk_touch_info fail\n"); + return -1; + } + + if(ts->get_touch_info) + { + ts->get_touch_info(ts,&point_num,info_buf); + } + for(i=0; i< point_num; i++) + { + input_mt_slot(ts->input_dev, i); + input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); + input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, info_buf[i].status); + input_report_abs(ts->input_dev, ABS_MT_POSITION_X, info_buf[i].x); + input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, info_buf[i].y); + #ifdef fjp_debug + printk("touch point %d %s >>x:%d>>y:%d\n",i,info_buf[i].status? "down":"up",info_buf[i].x,info_buf[i].y);//add by fjp 2010-9-28 + #endif + if(!info_buf[i].status) + { + input_mt_slot(ts->input_dev, i); + input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false); + } + + } + input_sync(ts->input_dev); + + if(gpio_get_value(ts->irq_pin) == GPIO_LOW) + { + #ifdef fjp_debug + printk("touch down .............\n");//add by fjp 2010-9-28 + #endif + queue_delayed_work(ts->ts_wq, &ts->ts_work,msecs_to_jiffies(30)); + goto exit; + + } + else + { + #ifdef fjp_debug + printk("touch up>>x:%d>>y:%d\n",info_buf[0].x,info_buf[0].y);//add by fjp 2010-9-28 + #endif + input_mt_slot(ts->input_dev, 0); + input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); + input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); + //input_report_abs(ts->input_dev, ABS_MT_POSITION_X, info_buf[0].x); + //input_report_abs(ts->input_dev, ABS_MT_POSITION_Y, info_buf[0].y); + input_mt_slot(ts->input_dev, 0); + input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false); + input_sync(ts->input_dev); + ts->pendown =PEN_RELEASE; + + + } + + enable_irq(ts->irq); +exit: + kfree(info_buf); + return 0; + } + + + + +/******************************************************* +Description: + Timer interrupt service routine. + +Parameter: + timer: timer struct pointer. + +return: + Timer work mode. HRTIMER_NORESTART---not restart mode +*******************************************************/ +static enum hrtimer_restart goodix_ts_timer_func(struct hrtimer *timer) +{ + struct rk_ts_data *ts = container_of(timer, struct rk_ts_data, timer); + queue_delayed_work(goodix_wq,&ts->ts_work,0); + hrtimer_start(&ts->timer, ktime_set(0, (POLL_TIME+6)*1000000), HRTIMER_MODE_REL); + return HRTIMER_NORESTART; +} + +/******************************************************* +Description: + External interrupt service routine. + +Parameter: + irq: interrupt number. + dev_id: private data pointer. + +return: + irq execute status. +*******************************************************/ +static irqreturn_t rk_ts_irq_handler(int irq, void *dev_id) +{ + + struct rk_ts_data *ts = (struct rk_ts_data*)dev_id; +#ifdef fjp_debug + printk("entry goodix_ts_irq_handler irq:%d\n",ts->irq);//add by fjp 2010-9-28 +#endif + disable_irq_nosync(ts->irq); + queue_delayed_work(ts->ts_wq, &ts->ts_work,0); + + return IRQ_HANDLED; +} + +static int rk_ts_suspend(struct i2c_client *client, pm_message_t mesg) +{ + int ret; + struct rk_ts_data *ts = i2c_get_clientdata(client); + + + + disable_irq(ts->irq); + +#if 1 + if (ts->power) { + ret = ts->power(ts, 0); + if (ret < 0) + printk(KERN_ERR "goodix_ts_resume power off failed\n"); + } +#endif + return 0; +} + +static int rk_ts_resume(struct i2c_client *client) +{ + int ret; + struct rk_ts_data *ts = i2c_get_clientdata(client); + +#if 1 + if (ts->power) { + ret = ts->power(ts, 1); + if (ret < 0) + printk(KERN_ERR "goodix_ts_resume power on failed\n"); + } +#endif + + enable_irq(client->irq); + + return 0; +} + + + +#ifdef CONFIG_HAS_EARLYSUSPEND +static void rk_ts_early_suspend(struct early_suspend *h) +{ + struct rk_ts_data *ts; + ts = container_of(h, struct rk_ts_data, early_suspend); + rk_ts_suspend(ts->client, PMSG_SUSPEND); +} + +static void rk_ts_late_resume(struct early_suspend *h) +{ + struct rk_ts_data *ts; + ts = container_of(h, struct rk_ts_data, early_suspend); + rk_ts_resume(ts->client); +} +#endif + +/******************************************************* +Description: + Goodix touchscreen power manage function. + +Parameter: + on: power status.0---suspend;1---resume. + +return: + Executive outcomes.-1---i2c transfer error;0---succeed. +*******************************************************/ +static int goodix_ts_power(struct rk_ts_data * ts, int on) +{ + int ret = -1; + unsigned char i2c_control_buf[2] = {80, 1}; //suspend cmd + int retry = 0; + if(on != 0 && on !=1) + { + printk(KERN_DEBUG "%s: Cant't support this command.", rk_ts_name); + return -EINVAL; + } + + + if(on == 0) //suspend + { + while(retry<5) + { + ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); + if(ret == 1) + { + printk(KERN_INFO"Send suspend cmd\n"); + break; + } + retry++; + msleep(10); + } + if(ret > 0) + ret = 0; + } + else if(on == 1) //resume + { + printk(KERN_INFO"Int resume\n"); + gpio_set_value(RK29_PIN6_PC3,GPIO_LOW); + msleep(20); + gpio_set_value(RK29_PIN6_PC3,GPIO_HIGH); + ret = 0; + } + return ret; +} + + +static int goodix_input_params_init(struct rk_ts_data *ts) +{ + int ret ; + ts->input_dev = input_allocate_device(); + if (ts->input_dev == NULL) { + ret = -ENOMEM; + printk(KERN_ALERT "Failed to allocate input device\n"); + return ret; + } + + + __set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit); + __set_bit(EV_ABS, ts->input_dev->evbit); + + input_mt_init_slots(ts->input_dev, MAX_SUPPORT_POINT); + input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); + input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, ts->abs_x_max, 0, 0); + input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, ts->abs_y_max, 0, 0); + sprintf(ts->phys, "input/ts"); + ts->input_dev->name = rk_ts_name; + ts->input_dev->phys = ts->phys; + ts->input_dev->id.bustype = BUS_I2C; + ts->input_dev->id.vendor = 0xDEAD; + ts->input_dev->id.product = 0xBEEF; + ts->input_dev->id.version = 10427; //screen firmware version + + ret = input_register_device(ts->input_dev); + if (ret) { + printk(KERN_ALERT "Probe: Unable to register %s input device\n", ts->input_dev->name); + return -1; + } + ts->bad_data = 0; + + return 0 ; + +} + +static int goodix_ts_init(struct rk_ts_data *ts) +{ + char retry; + char ret ; + char test_data = 1; + char *version_info = NULL; + for(retry=0;retry < 30; retry++) //test goodix + { + ret =goodix_i2c_write_bytes(ts->client, &test_data, 1); + if (ret > 0) + break; + } + if(ret <= 0) + { + printk(KERN_INFO "I2C communication ERROR!Goodix touchscreen driver become invalid\n"); + return -1; + } + + + ret=goodix_init_panel(ts); + if(ret != 0) { + printk("goodix panel init fail\n"); + ts->bad_data=1; + return -1; + } + else + { + printk(KERN_INFO "%s>>>>>>>max_point %d\n",__func__,ts->max_touch_num); + } + ret = goodix_read_version(ts, &version_info); + if(ret <= 0) + { + printk(KERN_INFO"Read version data failed!\n"); + } + else + { + printk(KERN_INFO"Goodix TouchScreen Version:%s>>>max_point:%d\n", (version_info+1),ts->max_touch_num); + } + vfree(version_info); + #ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP + goodix_proc_entry = create_proc_entry("goodix-update", 0666, NULL); + if(goodix_proc_entry == NULL) + { + printk("Couldn't create proc entry!\n"); + ret = -ENOMEM; + return ret ; + } + else + { + printk("Create proc entry success!\n"); + goodix_proc_entry->write_proc = goodix_update_write; + goodix_proc_entry->read_proc = goodix_update_read; + //goodix_proc_entry->owner = THIS_MODULE; + } +#endif + + return 0; +} +/******************************************************* +Description: + Goodix touchscreen probe function. + +Parameter: + client: i2c device struct. + id:device id. + +return: + Executive outcomes. 0---succeed. +*******************************************************/ +static int rk_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + int ret = 0; + struct rk_ts_data *ts; + struct goodix_platform_data *pdata ; + + printk(KERN_INFO "Install touch driver.\n"); + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + { + dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n"); + ret = -ENODEV; + goto err_check_functionality_failed; + } + + ts = kzalloc(sizeof(struct rk_ts_data), GFP_KERNEL); + if (ts == NULL) { + printk(KERN_ALERT "alloc for struct rk_ts_data fail\n"); + ret = -ENOMEM; + goto err_alloc_data_failed; + } + + pdata = client->dev.platform_data; + ts->abs_x_max = TS_MAX_X; + ts->abs_y_max = TS_MAX_Y; + ts->irq_pin = pdata->irq_pin; + ts->pendown =PEN_RELEASE; + ts->client = client; + ts->ts_init = goodix_ts_init; + ts->power = goodix_ts_power; + ts->get_touch_info = goodix_get_touch_info; + ts->input_parms_init = goodix_input_params_init; + i2c_set_clientdata(client, ts); + + + if (pdata->init_platform_hw) + { + pdata->init_platform_hw(); + } + + if(ts->ts_init) + { + ret = ts->ts_init(ts); + if(ret < 0) + { + printk(KERN_ALERT "rk ts init fail\n"); + //return -1; + } + } + + if(ts->input_parms_init) + { + ts->input_parms_init(ts); + } + + i2c_connect_client = client; + #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32) + ts->ts_wq= create_rt_workqueue("rk_ts_wq"); //create a work queue and worker thread + #else + ts->ts_wq= create_workqueue("rk_ts_wq"); + #endif + if (!ts->ts_wq){ + printk(KERN_ALERT "creat touch screen workqueue failed\n"); + return -ENOMEM; + } + + INIT_DELAYED_WORK(&ts->ts_work, rk_ts_work_func); +#ifdef CONFIG_HAS_EARLYSUSPEND + ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + ts->early_suspend.suspend = rk_ts_early_suspend; + ts->early_suspend.resume = rk_ts_late_resume; + register_early_suspend(&ts->early_suspend); +#endif + + + + + ts->irq=gpio_to_irq(ts->irq_pin) ; //If not defined in client + if (ts->irq) + { + ret = gpio_request(pdata->irq_pin, "TS_IRQ_PIN"); //Request IO + if (ret < 0) + { + printk(KERN_ALERT "Failed to request for touch irq\n"); + goto err_gpio_request_failed; + } + else + { + gpio_direction_input(pdata->irq_pin); + } + + ret = request_irq(ts->irq, rk_ts_irq_handler ,IRQ_TYPE_LEVEL_LOW,client->name, ts); + if (ret != 0) { + printk(KERN_ALERT "Cannot allocate ts INT!ERRNO:%d\n", ret); + gpio_free(INT_PORT); + goto err_gpio_request_failed; + } + else + { + enable_irq(ts->irq); + + } + } + printk("Goodix TS probe successfully! max_x:%d>>max_y:%d>>max_support_point:%d\n", + ts->abs_x_max,ts->abs_y_max,ts->max_touch_num); + return 0; +err_init_godix_ts: + if(ts->use_irq) + { + ts->use_irq = 0; + free_irq(client->irq,ts); + #ifdef INT_PORT + gpio_direction_input(INT_PORT); + gpio_free(INT_PORT); + #endif + } + else + hrtimer_cancel(&ts->timer); + +err_gpio_request_failed: +err_input_register_device_failed: + input_free_device(ts->input_dev); + +err_input_dev_alloc_failed: + i2c_set_clientdata(client, NULL); +err_i2c_failed: + kfree(ts); +err_alloc_data_failed: +err_check_functionality_failed: +err_create_proc_entry: + return ret; +} + + +/******************************************************* +Description: + Goodix touchscreen driver release function. + +Parameter: + client: i2c device struct. + +return: + Executive outcomes. 0---succeed. +*******************************************************/ +static int rk_ts_remove(struct i2c_client *client) +{ + struct rk_ts_data *ts = i2c_get_clientdata(client); +#ifdef CONFIG_HAS_EARLYSUSPEND + unregister_early_suspend(&ts->early_suspend); +#endif +#ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP + remove_proc_entry("goodix-update", NULL); +#endif + //goodix_debug_sysfs_deinit(); + if (ts && ts->use_irq) + { + #ifdef INT_PORT + gpio_direction_input(INT_PORT); + gpio_free(INT_PORT); + #endif + free_irq(client->irq, ts); + } + else if(ts) + hrtimer_cancel(&ts->timer); + + dev_notice(&client->dev,"The driver is removing...\n"); + i2c_set_clientdata(client, NULL); + input_unregister_device(ts->input_dev); + kfree(ts); + return 0; +} + + + +//******************************Begin of firmware update surpport******************************* +#ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP +/** +@brief CRC cal proc,include : Reflect,init_crc32_table,GenerateCRC32 +@param global var oldcrc32 +@return states +*/ +static unsigned int Reflect(unsigned long int ref, char ch) +{ + unsigned int value=0; + int i; + for(i = 1; i < (ch + 1); i++) + { + if(ref & 1) + value |= 1 << (ch - i); + ref >>= 1; + } + return value; +} +/*---------------------------------------------------------------------------------------------------------*/ +/* CRC Check Program INIT */ +/*---------------------------------------------------------------------------------------------------------*/ +static void init_crc32_table(void) +{ + unsigned int temp; + unsigned int t1,t2; + unsigned int flag; + int i,j; + for(i = 0; i <= 0xFF; i++) + { + temp=Reflect(i, 8); + crc32_table[i]= temp<< 24; + for (j = 0; j < 8; j++) + { + + flag=crc32_table[i]&0x80000000; + t1=(crc32_table[i] << 1); + if(flag==0) + t2=0; + else + t2=ulPolynomial; + crc32_table[i] =t1^t2 ; + + } + crc32_table[i] = Reflect(crc32_table[i], 32); + } +} +/*---------------------------------------------------------------------------------------------------------*/ +/* CRC main Program */ +/*---------------------------------------------------------------------------------------------------------*/ +static void GenerateCRC32(unsigned char * buf, unsigned int len) +{ + unsigned int i; + unsigned int t; + + for (i = 0; i != len; ++i) + { + t = (oldcrc32 ^ buf[i]) & 0xFF; + oldcrc32 = ((oldcrc32 >> 8) & 0xFFFFFF) ^ crc32_table[t]; + } +} + +static struct file * update_file_open(char * path, mm_segment_t * old_fs_p) +{ + struct file * filp = NULL; + int errno = -1; + + filp = filp_open(path, O_RDONLY, 0644); + + if(!filp || IS_ERR(filp)) + { + if(!filp) + errno = -ENOENT; + else + errno = PTR_ERR(filp); + printk(KERN_ERR "The update file for Guitar open error.\n"); + return NULL; + } + *old_fs_p = get_fs(); + set_fs(get_ds()); + + filp->f_op->llseek(filp,0,0); + return filp ; +} + +static void update_file_close(struct file * filp, mm_segment_t old_fs) +{ + set_fs(old_fs); + if(filp) + filp_close(filp, NULL); +} +static int update_get_flen(char * path) +{ + struct file * file_ck = NULL; + mm_segment_t old_fs; + int length ; + + file_ck = update_file_open(path, &old_fs); + if(file_ck == NULL) + return 0; + + length = file_ck->f_op->llseek(file_ck, 0, SEEK_END); + //printk("File length: %d\n", length); + if(length < 0) + length = 0; + update_file_close(file_ck, old_fs); + return length; +} +static int update_file_check(char * path) +{ + unsigned char buffer[64] = { 0 } ; + struct file * file_ck = NULL; + mm_segment_t old_fs; + int count, ret, length ; + + file_ck = update_file_open(path, &old_fs); + + if(path != NULL) + printk("File Path:%s\n", path); + + if(file_ck == NULL) + return -ERROR_NO_FILE; + + length = file_ck->f_op->llseek(file_ck, 0, SEEK_END); +#ifdef GUITAR_MESSAGE + printk(KERN_INFO "gt801 update: File length: %d\n",length); +#endif + if(length <= 0 || (length%4) != 0) + { + update_file_close(file_ck, old_fs); + return -ERROR_FILE_TYPE; + } + + //set file point to the begining of the file + file_ck->f_op->llseek(file_ck, 0, SEEK_SET); + oldcrc32 = 0xFFFFFFFF; + init_crc32_table(); + while(length > 0) + { + ret = file_ck->f_op->read(file_ck, buffer, sizeof(buffer), &file_ck->f_pos); + if(ret > 0) + { + for(count = 0; count < ret; count++) + GenerateCRC32(&buffer[count],1); + } + else + { + update_file_close(file_ck, old_fs); + return -ERROR_FILE_READ; + } + length -= ret; + } + oldcrc32 = ~oldcrc32; +#ifdef GUITAR_MESSAGE + printk("CRC_Check: %u\n", oldcrc32); +#endif + update_file_close(file_ck, old_fs); + return 1; +} + +unsigned char wait_slave_ready(struct rk_ts_data *ts, unsigned short *timeout) +{ + unsigned char i2c_state_buf[2] = {ADDR_STA, UNKNOWN_ERROR}; + int ret; + while(*timeout < MAX_TIMEOUT) + { + ret = goodix_i2c_read_bytes(ts->client, i2c_state_buf, 2); + if(ret <= 0) + return ERROR_I2C_TRANSFER; + if(i2c_state_buf[1] & SLAVE_READY) + { + return i2c_state_buf[1]; + //return 1; + } + msleep(10); + *timeout += 5; + } + return 0; +} + +static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data) +{ + unsigned char cmd[220]; + int ret = -1; + + static unsigned char update_path[100]; + static unsigned short time_count = 0; + static unsigned int file_len = 0; + + unsigned char i2c_control_buf[2] = {ADDR_CMD, 0}; + unsigned char i2c_states_buf[2] = {ADDR_STA, 0}; + unsigned char i2c_data_buf[PACK_SIZE+1+8] = {ADDR_DAT,}; + //unsigned char i2c_rd_buf[1+4+PACK_SIZE+4]; + unsigned char i2c_rd_buf[160]; + unsigned char retries = 0; + unsigned int rd_len; + unsigned char i = 0; + static unsigned char update_need_config = 0; + + unsigned char checksum_error_times = 0; +#ifdef UPDATE_NEW_PROTOCOL + unsigned int frame_checksum = 0; + unsigned int frame_number = 0; +#else + unsigned char send_crc = 0; +#endif + + struct file * file_data = NULL; + mm_segment_t old_fs; + struct rk_ts_data *ts; + + ts = i2c_get_clientdata(i2c_connect_client); + if(ts==NULL) + return 0; + + if(copy_from_user(&cmd, buff, len)) + { + return -EFAULT; + } + switch(cmd[0]) + { + case STEP_SET_PATH: + printk(KERN_INFO"Write cmd is:%d,cmd arg is:%s,write len is:%ld\n",cmd[0], &cmd[1], len); + memset(update_path, 0, 100); + strncpy(update_path, cmd+1, 100); + if(update_path[0] == 0) + return 0; + else + return 1; + case STEP_CHECK_FILE: + printk(KERN_INFO"Begin to firmware update ......\n"); + ret = update_file_check(update_path); + if(ret <= 0) + { + printk(KERN_INFO"fialed to check update file!\n"); + return ret; + } + msleep(500); + printk(KERN_INFO"Update check file success!\n"); + return 1; + case STEP_WRITE_SYN: + printk(KERN_INFO"STEP1:Write synchronization signal!\n"); + i2c_control_buf[1] = UPDATE_START; + ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); + if(ret <= 0) + { + ret = ERROR_I2C_TRANSFER; + return ret; + } + //the time include time(APROM -> LDROM) and time(LDROM init) + msleep(1000); + return 1; + case STEP_WAIT_SYN: + printk(KERN_INFO"STEP2:Wait synchronization signal!\n"); + while(retries < MAX_I2C_RETRIES) + { + i2c_states_buf[1] = UNKNOWN_ERROR; + ret = goodix_i2c_read_bytes(ts->client, i2c_states_buf, 2); + printk(KERN_INFO"The read byte is:%d\n", i2c_states_buf[1]); + if(i2c_states_buf[1] & UPDATE_START) + { + if(i2c_states_buf[1] & NEW_UPDATE_START) + { + #ifdef UPDATE_NEW_PROTOCOL + update_need_config = 1; + return 2; + #else + return 1; + #endif + } + break; + } + msleep(5); + retries++; + time_count += 10; + } + if((retries >= MAX_I2C_RETRIES) && (!(i2c_states_buf[1] & UPDATE_START))) + { + if(ret <= 0) + return 0; + else + return -1; + } + return 1; + case STEP_WRITE_LENGTH: + printk(KERN_INFO"STEP3:Write total update file length!\n"); + file_len = update_get_flen(update_path); + if(file_len <= 0) + { + printk(KERN_INFO"get update file length failed!\n"); + return -1; + } + file_len += 4; + i2c_data_buf[1] = (file_len>>24) & 0xff; + i2c_data_buf[2] = (file_len>>16) & 0xff; + i2c_data_buf[3] = (file_len>>8) & 0xff; + i2c_data_buf[4] = file_len & 0xff; + file_len -= 4; + ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, 5); + if(ret <= 0) + { + ret = ERROR_I2C_TRANSFER; + return 0; + } + return 1; + case STEP_WAIT_READY: + printk(KERN_INFO"STEP4:Wait slave ready!\n"); + ret = wait_slave_ready(ts, &time_count); + if(ret == ERROR_I2C_TRANSFER) + return 0; + if(!ret) + { + return -1; + } + printk(KERN_INFO"Slave ready!\n"); + return 1; + case STEP_WRITE_DATA: +#ifdef UPDATE_NEW_PROTOCOL + printk(KERN_INFO"STEP5:Begin to send file data use NEW protocol!\n"); + file_data = update_file_open(update_path, &old_fs); + if(file_data == NULL) + { + return -1; + } + frame_number = 0; + while(file_len >= 0) + { + i2c_data_buf[0] = ADDR_DAT; + rd_len = (file_len >= PACK_SIZE) ? PACK_SIZE : file_len; + frame_checksum = 0; + if(file_len) + { + ret = file_data->f_op->read(file_data, i2c_data_buf+1+4, rd_len, &file_data->f_pos); + if(ret <= 0) + { + printk("[GOODiX_ISP_NEW]:Read File Data Failed!\n"); + return -1; + } + i2c_data_buf[1] = (frame_number>>24)&0xff; + i2c_data_buf[2] = (frame_number>>16)&0xff; + i2c_data_buf[3] = (frame_number>>8)&0xff; + i2c_data_buf[4] = frame_number&0xff; + frame_number++; + frame_checksum = 0; + for(i=0; i>8)&0xff; + i2c_data_buf[5+rd_len+2] = (frame_checksum>>16)&0xff; + i2c_data_buf[5+rd_len+3] = (frame_checksum>>24)&0xff; + } +rewrite: + printk(KERN_INFO"[GOODiX_ISP_NEW]:%d\n", file_len); + ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, 1+4+rd_len+4); + //if(ret <= 0) + if(ret != 1) + { + printk("[GOODiX_ISP_NEW]:Write File Data Failed!Return:%d\n", ret); + return 0; + } + + memset(i2c_rd_buf, 0x00, 1+4+rd_len+4); + ret = goodix_i2c_read_bytes(ts->client, i2c_rd_buf, 1+4+rd_len+4); + if(ret != 2) + { + printk("[GOODiX_ISP_NEW]:Read File Data Failed!Return:%d\n", ret); + return 0; + } + for(i=1; i<(1+4+rd_len+4); i++) //check communication + { + if(i2c_rd_buf[i] != i2c_data_buf[i]) + { + i = 0; + break; + } + } + if(!i) + { + i2c_control_buf[0] = ADDR_CMD; + i2c_control_buf[1] = 0x03; + goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //communication error + printk("[GOODiX_ISP_NEW]:File Data Frame readback check Error!\n"); + } + else + { + i2c_control_buf[1] = 0x04; //let LDROM write flash + goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); + } + + //Wait for slave ready signal.and read the checksum + ret = wait_slave_ready(ts, &time_count); + if((ret & CHECKSUM_ERROR)||(!i)) + { + if(i) + { + printk("[GOODiX_ISP_NEW]:File Data Frame checksum Error!\n"); + } + checksum_error_times++; + msleep(20); + if(checksum_error_times > 20) //max retry times. + return 0; + goto rewrite; + } + checksum_error_times = 0; + if(ret & (FRAME_ERROR)) + { + printk("[GOODiX_ISP_NEW]:File Data Frame Miss!\n"); + return 0; + } + if(ret == ERROR_I2C_TRANSFER) + return 0; + if(!ret) + { + return -1; + } + if(file_len < PACK_SIZE) + { + update_file_close(file_data, old_fs); + break; + } + file_len -= rd_len; + }//end of while((file_len >= 0)) + return 1; +#else + printk(KERN_INFO"STEP5:Begin to send file data use OLD protocol!\n"); + file_data = update_file_open(update_path, &old_fs); + if(file_data == NULL) //file_data has been opened at the last time + { + return -1; + } + while((file_len >= 0) && (!send_crc)) + { + printk(KERN_INFO"[GOODiX_ISP_OLD]:%d\n", file_len); + i2c_data_buf[0] = ADDR_DAT; + rd_len = (file_len >= PACK_SIZE) ? PACK_SIZE : file_len; + if(file_len) + { + ret = file_data->f_op->read(file_data, i2c_data_buf+1, rd_len, &file_data->f_pos); + if(ret <= 0) + { + return -1; + } + } + if(file_len < PACK_SIZE) + { + send_crc = 1; + update_file_close(file_data, old_fs); + i2c_data_buf[file_len+1] = oldcrc32&0xff; + i2c_data_buf[file_len+2] = (oldcrc32>>8)&0xff; + i2c_data_buf[file_len+3] = (oldcrc32>>16)&0xff; + i2c_data_buf[file_len+4] = (oldcrc32>>24)&0xff; + ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, (file_len+1+4)); + //if(ret <= 0) + if(ret != 1) + { + printk("[GOODiX_ISP_OLD]:Write File Data Failed!Return:%d\n", ret); + return 0; + } + break; + } + else + { + ret = goodix_i2c_write_bytes(ts->client, i2c_data_buf, PACK_SIZE+1); + //if(ret <= 0) + if(ret != 1) + { + printk("[GOODiX_ISP_OLD]:Write File Data Failed!Return:%d\n", ret); + return 0; + } + } + file_len -= rd_len; + + //Wait for slave ready signal. + ret = wait_slave_ready(ts, &time_count); + if(ret == ERROR_I2C_TRANSFER) + return 0; + if(!ret) + { + return -1; + } + //Slave is ready. + }//end of while((file_len >= 0) && (!send_crc)) + return 1; +#endif + case STEP_READ_STATUS: + printk(KERN_INFO"STEP6:Read update status!\n"); + while(time_count < MAX_TIMEOUT) + { + ret = goodix_i2c_read_bytes(ts->client, i2c_states_buf, 2); + if(ret <= 0) + { + return 0; + } + if(i2c_states_buf[1] & SLAVE_READY) + { + if(!(i2c_states_buf[1] &0xf0)) + { + printk(KERN_INFO"The firmware updating succeed!update state:0x%x\n",i2c_states_buf[1]); + return 1; + } + else + { + printk(KERN_INFO"The firmware updating failed!update state:0x%x\n",i2c_states_buf[1]); + return 0; + + } + } + msleep(1); + time_count += 5; + } + return -1; + case FUN_CLR_VAL: //clear the static val + time_count = 0; + file_len = 0; + update_need_config = 0; + return 1; + case FUN_CMD: //functional command + if(cmd[1] == CMD_DISABLE_TP) + { + printk(KERN_INFO"Disable TS int!\n"); + g_enter_isp = 1; + if(ts->use_irq) + disable_irq(TS_INT); + } + else if(cmd[1] == CMD_ENABLE_TP) + { + printk(KERN_INFO"Enable TS int!\n"); + g_enter_isp = 0; + if(ts->use_irq) + enable_irq(TS_INT); + } + else if(cmd[1] == CMD_READ_VER) + { + printk(KERN_INFO"Read version!\n"); + ts->read_mode = MODE_RD_VER; + } + else if(cmd[1] == CMD_READ_RAW) + { + printk(KERN_INFO"Read raw data!\n"); + ts->read_mode = MODE_RD_RAW; + i2c_control_buf[1] = 201; + ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //read raw data cmd + if(ret <= 0) + { + printk(KERN_INFO"Write read raw data cmd failed!\n"); + return 0; + } + msleep(200); + } + else if(cmd[1] == CMD_READ_DIF) + { + printk(KERN_INFO"Read diff data!\n"); + ts->read_mode = MODE_RD_DIF; + i2c_control_buf[1] = 202; + ret = goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); //read diff data cmd + if(ret <= 0) + { + printk(KERN_INFO"Write read raw data cmd failed!\n"); + return 0; + } + msleep(200); + } + else if(cmd[1] == CMD_READ_CFG) + { + printk(KERN_INFO"Read config info!\n"); + ts->read_mode = MODE_RD_CFG; + rd_cfg_addr = cmd[2]; + rd_cfg_len = cmd[3]; + } + else if(cmd[1] == CMD_SYS_REBOOT) + { + printk(KERN_INFO"System reboot!\n"); + sys_sync(); + msleep(200); + kernel_restart(NULL); + } + return 1; + case FUN_WRITE_CONFIG: + + printk(KERN_INFO"Begin write config info!Config length:%d\n",cmd[1]); + for(i=3; i83)&&(cmd[2]<240)&&cmd[1]) + { + checksum_error_times = 0; +reconfig: + ret = goodix_i2c_write_bytes(ts->client, cmd+2, cmd[1]); + if(ret != 1) + { + printk("Write Config failed!return:%d\n",ret); + return -1; + } + if(!update_need_config)return 1; + + i2c_rd_buf[0] = cmd[2]; + ret = goodix_i2c_read_bytes(ts->client, i2c_rd_buf, cmd[1]); + if(ret != 2) + { + printk("Read Config failed!return:%d\n",ret); + return -1; + } + for(i=0; iclient, i2c_control_buf, 2); //communication error + checksum_error_times++; + msleep(20); + if(checksum_error_times > 20) //max retry times. + return 0; + goto reconfig; + } + else + { + i2c_control_buf[0] = ADDR_CMD; + i2c_control_buf[1] = 0x04; //let LDROM write flash + goodix_i2c_write_bytes(ts->client, i2c_control_buf, 2); + return 1; + } + + } + else + { + printk(KERN_INFO"Invalid config addr!\n"); + return -1; + } + default: + return -ENOSYS; + } + return 0; +} + +static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data ) +{ + int ret = -1; + struct rk_ts_data *ts; + int len = 0; + char *version_info = NULL; + unsigned char read_data[1201] = {80, }; + + ts = i2c_get_clientdata(i2c_connect_client); + if(ts==NULL) + return 0; + + if(ts->read_mode == MODE_RD_VER) //read version data + { + ret = goodix_read_version(ts, &version_info); + if(ret <= 0) + { + printk(KERN_INFO"Read version data failed!\n"); + vfree(version_info); + return 0; + } + + for(len=0;len<100;len++) + { + if(*(version_info + len) == '\0') + break; + } + printk(KERN_INFO"GOODiX Touchscreen Version is:%s\n", (version_info+1)); + strncpy(page, version_info+1, len + 1); + vfree(version_info); + *eof = 1; + return len+1; + } + else if((ts->read_mode == MODE_RD_RAW)||(ts->read_mode == MODE_RD_DIF)) //read raw data or diff + { + //printk(KERN_INFO"Read raw data\n"); + ret = goodix_i2c_read_bytes(ts->client, read_data, 1201); + if(ret <= 0) + { + if(ts->read_mode == 2) + printk(KERN_INFO"Read raw data failed!\n"); + if(ts->read_mode == 3) + printk(KERN_INFO"Read diff data failed!\n"); + return 0; + } + memcpy(page, read_data+1, 1200); + *eof = 1; + *start = NULL; + return 1200; + } + else if(ts->read_mode == MODE_RD_CFG) + { + if((rd_cfg_addr>83)&&(rd_cfg_addr<240)) + { + read_data[0] = rd_cfg_addr; + printk("read config addr is:%d\n", rd_cfg_addr); + } + else + { + read_data[0] = 101; + printk("invalid read config addr,use default!\n"); + } + if((rd_cfg_len<0)||(rd_cfg_len>156)) + { + printk("invalid read config length,use default!\n"); + rd_cfg_len = 239 - read_data[0]; + } + printk("read config length is:%d\n", rd_cfg_len); + ret = goodix_i2c_read_bytes(ts->client, read_data, rd_cfg_len); + if(ret <= 0) + { + printk(KERN_INFO"Read config info failed!\n"); + return 0; + } + memcpy(page, read_data+1, rd_cfg_len); + return rd_cfg_len; + } + return len; +} + +#endif +//******************************End of firmware update surpport******************************* +static const struct i2c_device_id goodix_ts_id[] = { + { "Goodix-TS", 0 }, + { } +}; + +static struct i2c_driver rk_ts_driver = { + .probe = rk_ts_probe, + .remove = rk_ts_remove, +#ifndef CONFIG_HAS_EARLYSUSPEND + .suspend = rk_ts_suspend, + .resume = rk_ts_resume, +#endif + .id_table = goodix_ts_id, + .driver = { + .name = "Goodix-TS", + .owner = THIS_MODULE, + }, +}; + +/******************************************************* +Description: + Driver Install function. +return: + Executive Outcomes. 0---succeed. +********************************************************/ +static int __devinit rk_ts_init(void) +{ + int ret ; + ret=i2c_add_driver(&rk_ts_driver); + return ret; +} + +/******************************************************* +Description: + Driver uninstall function. +return: + Executive Outcomes. 0---succeed. +********************************************************/ +static void __exit rk_ts_exit(void) +{ + printk(KERN_ALERT "Touchscreen driver of guitar exited.\n"); + i2c_del_driver(&rk_ts_driver); +} + +module_init(rk_ts_init); +module_exit(rk_ts_exit); + +MODULE_DESCRIPTION("Goodix Touchscreen Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/input/touchscreen/rk29_i2c_goodix.h b/drivers/input/touchscreen/rk29_i2c_goodix.h new file mode 100755 index 000000000000..7edbe7c7da2b --- /dev/null +++ b/drivers/input/touchscreen/rk29_i2c_goodix.h @@ -0,0 +1,232 @@ +/* + * include/linux/goodix_touch.h + * + * Copyright (C) 2010 - 2011 Goodix, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +#ifndef _LINUX_GOODIX_TOUCH_H +#define _LINUX_GOODIX_TOUCH_H + +#include +#include +#include +#include + +//*************************TouchScreen Work Part***************************** + +#define GOODIX_I2C_NAME "Goodix-TS" +#define GOODIX_1024X768 1 + +#define TS_MAX_X 1024 +#define TS_MAX_Y 768 + +#if 1 +#define INT_PORT RK29_PIN0_PA2 +#ifdef INT_PORT + #define TS_INT gpio_to_irq(INT_PORT) +// #define INT_CFG S3C_GPIO_SFN(2) //IO configer as EINT +#else + #define TS_INT 0 +#endif + +//whether need send cfg? +//#define DRIVER_SEND_CFG + +//set trigger mode +#define INT_TRIGGER 0 + +#endif + +#define POLL_TIME 10 //actual query spacing interval:POLL_TIME+6 + +#define GOODIX_MULTI_TOUCH +#ifdef GOODIX_MULTI_TOUCH + #define MAX_FINGER_NUM 10 +#else + #define MAX_FINGER_NUM 1 +#endif + +//#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0) + +struct rk_touch_info +{ + u32 status; // 1:down,0:up + u32 x ; + u32 y ; +} ; +struct rk_ts_data{ + uint16_t addr; + uint8_t bad_data; + struct i2c_client *client; + struct input_dev *input_dev; + int use_reset; //use RESET flag + int use_irq; //use EINT flag + int irq; + int irq_pin; + int read_mode; //read moudle mode,20110221 by andrew + struct hrtimer timer; + struct workqueue_struct *ts_wq; + struct delayed_work ts_work; + char phys[32]; + int retry; + struct early_suspend early_suspend; + int (*power)(struct rk_ts_data * ts, int on); + int (*ts_init)(struct rk_ts_data*ts); + int (*input_parms_init)(struct rk_ts_data *ts); + void (*get_touch_info)(struct rk_ts_data *ts,char *point_num,struct rk_touch_info *info_buf); //get touch data info + uint16_t abs_x_max; + uint16_t abs_y_max; + uint8_t max_touch_num; + uint8_t int_trigger_type; + bool pendown; +}; + + + +struct goodix_ts_data { + uint16_t addr; + uint8_t bad_data; + struct i2c_client *client; + struct input_dev *input_dev; + int use_reset; //use RESET flag + int use_irq; //use EINT flag + int read_mode; //read moudle mode,20110221 by andrew + struct hrtimer timer; + struct delayed_work work; + char phys[32]; + int retry; + struct early_suspend early_suspend; + int (*power)(struct goodix_ts_data * ts, int on); + uint16_t abs_x_max; + uint16_t abs_y_max; + uint8_t max_touch_num; + uint8_t int_trigger_type; + bool pendown; +}; + +static const char *rk_ts_name = "Goodix Capacitive TouchScreen"; +static struct workqueue_struct *goodix_wq; +struct i2c_client * i2c_connect_client = NULL; +static struct proc_dir_entry *goodix_proc_entry; +//static struct kobject *goodix_debug_kobj; + +#ifdef CONFIG_HAS_EARLYSUSPEND +static void goodix_ts_early_suspend(struct early_suspend *h); +static void goodix_ts_late_resume(struct early_suspend *h); +#endif + +#define READ_COOR_ADDR 0x01 + +//*****************************End of Part I ********************************* + +//*************************Touchkey Surpport Part***************************** +//#define HAVE_TOUCH_KEY +#ifdef HAVE_TOUCH_KEY + #define READ_COOR_ADDR 0x00 + const uint16_t touch_key_array[]={ + KEY_MENU, //MENU + KEY_HOME, //HOME + KEY_SEND //CALL + }; + #define MAX_KEY_NUM (sizeof(touch_key_array)/sizeof(touch_key_array[0])) +#else + #define READ_COOR_ADDR 0x01 +#endif +//*****************************End of Part II********************************* +#if 1 +//*************************Firmware Update part******************************* +#define CONFIG_TOUCHSCREEN_GOODIX_IAP +#ifdef CONFIG_TOUCHSCREEN_GOODIX_IAP +#define UPDATE_NEW_PROTOCOL + +unsigned int oldcrc32 = 0xFFFFFFFF; +unsigned int crc32_table[256]; +unsigned int ulPolynomial = 0x04c11db7; +unsigned char rd_cfg_addr; +unsigned char rd_cfg_len; +unsigned char g_enter_isp = 0; + +static int goodix_update_write(struct file *filp, const char __user *buff, unsigned long len, void *data); +static int goodix_update_read( char *page, char **start, off_t off, int count, int *eof, void *data ); + +#define PACK_SIZE 64 //update file package size +#define MAX_TIMEOUT 60000 //update time out conut +#define MAX_I2C_RETRIES 20 //i2c retry times + +//I2C buf address +#define ADDR_CMD 80 +#define ADDR_STA 81 +#ifdef UPDATE_NEW_PROTOCOL + #define ADDR_DAT 0 +#else + #define ADDR_DAT 82 +#endif + +//moudle state +#define NEW_UPDATE_START 0x01 +#define UPDATE_START 0x02 +#define SLAVE_READY 0x08 +#define UNKNOWN_ERROR 0x00 +#define FRAME_ERROR 0x10 +#define CHECKSUM_ERROR 0x20 +#define TRANSLATE_ERROR 0x40 +#define FLASH_ERROR 0X80 + +//error no +#define ERROR_NO_FILE 2 //ENOENT +#define ERROR_FILE_READ 23 //ENFILE +#define ERROR_FILE_TYPE 21 //EISDIR +#define ERROR_GPIO_REQUEST 4 //EINTR +#define ERROR_I2C_TRANSFER 5 //EIO +#define ERROR_NO_RESPONSE 16 //EBUSY +#define ERROR_TIMEOUT 110 //ETIMEDOUT + +//update steps +#define STEP_SET_PATH 1 +#define STEP_CHECK_FILE 2 +#define STEP_WRITE_SYN 3 +#define STEP_WAIT_SYN 4 +#define STEP_WRITE_LENGTH 5 +#define STEP_WAIT_READY 6 +#define STEP_WRITE_DATA 7 +#define STEP_READ_STATUS 8 +#define FUN_CLR_VAL 9 +#define FUN_CMD 10 +#define FUN_WRITE_CONFIG 11 + +//fun cmd +#define CMD_DISABLE_TP 0 +#define CMD_ENABLE_TP 1 +#define CMD_READ_VER 2 +#define CMD_READ_RAW 3 +#define CMD_READ_DIF 4 +#define CMD_READ_CFG 5 +#define CMD_SYS_REBOOT 101 + +//read mode +#define MODE_RD_VER 1 +#define MODE_RD_RAW 2 +#define MODE_RD_DIF 3 +#define MODE_RD_CFG 4 + + +#endif +//*****************************End of Part III******************************** +#endif +struct goodix_i2c_platform_data { + uint32_t version; /* Use this entry for panels with */ + //reservation +}; + +#endif /* _LINUX_GOODIX_TOUCH_H */ diff --git a/drivers/media/video/gc0309.c b/drivers/media/video/gc0309.c index 6c458ae808a7..7ef21f43d2d3 100755 --- a/drivers/media/video/gc0309.c +++ b/drivers/media/video/gc0309.c @@ -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; diff --git a/drivers/media/video/rk29_camera.c b/drivers/media/video/rk29_camera.c index 106c2ecece07..160dad9947b6 100755 --- a/drivers/media/video/rk29_camera.c +++ b/drivers/media/video/rk29_camera.c @@ -97,6 +97,7 @@ static struct rk29camera_platform_data rk29_camera_platform_data = { .gpio_flash = CONFIG_SENSOR_FALSH_PIN_0, .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_0|CONFIG_SENSOR_RESETACTIVE_LEVEL_0|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_0|CONFIG_SENSOR_FLASHACTIVE_LEVEL_0), .gpio_init = 0, + .orientation = CONFIG_SENSOR_ORIENTATION_0, .dev_name = SENSOR_DEVICE_NAME_0, }, { .gpio_reset = CONFIG_SENSOR_RESET_PIN_1, @@ -105,6 +106,7 @@ static struct rk29camera_platform_data rk29_camera_platform_data = { .gpio_flash = CONFIG_SENSOR_FALSH_PIN_1, .gpio_flag = (CONFIG_SENSOR_POWERACTIVE_LEVEL_1|CONFIG_SENSOR_RESETACTIVE_LEVEL_1|CONFIG_SENSOR_POWERDNACTIVE_LEVEL_1|CONFIG_SENSOR_FLASHACTIVE_LEVEL_1), .gpio_init = 0, + .orientation = CONFIG_SENSOR_ORIENTATION_1, .dev_name = SENSOR_DEVICE_NAME_1, } }, @@ -1432,7 +1434,6 @@ static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, } break; } - default: { printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd); diff --git a/drivers/media/video/rk29_camera_oneframe.c b/drivers/media/video/rk29_camera_oneframe.c index f0b8b2b39b7b..14eddd0af8f7 100755 --- a/drivers/media/video/rk29_camera_oneframe.c +++ b/drivers/media/video/rk29_camera_oneframe.c @@ -48,7 +48,7 @@ module_param(debug, int, S_IRUGO|S_IWUSR); printk(KERN_WARNING"rk29xx_camera: " fmt , ## arg); } while (0) #define RK29CAMERA_TR(format, ...) printk(KERN_ERR format, ## __VA_ARGS__) -#define RK29CAMERA_DG(format, ...) dprintk(0, format, ## __VA_ARGS__) +#define RK29CAMERA_DG(format, ...) dprintk(1, format, ## __VA_ARGS__) // VIP Reg Offset #define RK29_VIP_AHBR_CTRL 0x00 @@ -1528,8 +1528,16 @@ static unsigned int rk29_camera_poll(struct file *file, poll_table *pt) static int rk29_camera_querycap(struct soc_camera_host *ici, struct v4l2_capability *cap) { - /* cap->name is set by the firendly caller:-> */ - strlcpy(cap->card, rk29_cam_driver_description, sizeof(cap->card)); + struct rk29_camera_dev *pcdev = ici->priv; + char orientation[5]; + + strlcpy(cap->card, dev_name(pcdev->icd->pdev), sizeof(cap->card)); + if (strcmp(dev_name(pcdev->icd->pdev), pcdev->pdata->gpio_res[0].dev_name) == 0) { + sprintf(orientation,"-%d",pcdev->pdata->gpio_res[0].orientation); + } else { + sprintf(orientation,"-%d",pcdev->pdata->gpio_res[1].orientation); + } + strcat(cap->card,orientation); cap->version = RK29_CAM_VERSION_CODE; cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c old mode 100644 new mode 100755 index 11a390a02e28..1bfd65bd3743 --- a/drivers/mfd/wm831x-core.c +++ b/drivers/mfd/wm831x-core.c @@ -1460,7 +1460,7 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) struct wm831x_pdata *pdata = wm831x->dev->platform_data; int rev; enum wm831x_parent parent; - int ret, i; + int ret; mutex_init(&wm831x->io_lock); mutex_init(&wm831x->key_lock); @@ -1558,15 +1558,6 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) dev_info(wm831x->dev, "WM8325 revision %c\n", 'A' + rev); break; -<<<<<<< HEAD - case WM8326: - parent = WM8326; - wm831x->num_gpio = 12; - dev_info(wm831x->dev, "WM8326 revision %c\n", 'A' + rev); - break; - -======= ->>>>>>> parent of 15f7fab... temp revert rk change default: dev_err(wm831x->dev, "Unknown WM831x device %04x\n", ret); ret = -EINVAL; @@ -1601,17 +1592,6 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) } } - if (pdata) { - for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) { - if (!pdata->gpio_defaults[i]) - continue; - - wm831x_reg_write(wm831x, - WM831X_GPIO1_CONTROL + i, - pdata->gpio_defaults[i] & 0xffff); - } - } - ret = wm831x_irq_init(wm831x, irq); if (ret != 0) goto err; @@ -1647,9 +1627,12 @@ int wm831x_device_init(struct wm831x *wm831x, unsigned long id, int irq) break; case WM8320: + ret = mfd_add_devices(wm831x->dev, -1, + wm8320_devs, ARRAY_SIZE(wm8320_devs), + NULL, 0); + break; + case WM8321: - case WM8325: - case WM8326: ret = mfd_add_devices(wm831x->dev, -1, wm8320_devs, ARRAY_SIZE(wm8320_devs), NULL, 0); @@ -1766,8 +1749,6 @@ int wm831x_device_suspend(struct wm831x *wm831x) return 0; } -<<<<<<< HEAD -======= void wm831x_enter_sleep(void){ #if 1//def CONFIG_RK2818_SOC_PM struct regulator *dcdc; @@ -1861,7 +1842,6 @@ int wm831x_device_restart(struct wm831x *wm831x) return 0; } ->>>>>>> parent of 15f7fab... temp revert rk change MODULE_DESCRIPTION("Core support for the WM831X AudioPlus PMIC"); MODULE_LICENSE("GPL"); diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c old mode 100644 new mode 100755 index a905baf527bb..9c840dcf1f04 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c @@ -52,27 +52,6 @@ static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg, int bytes, void *src) { struct i2c_client *i2c = wm831x->control_data; -<<<<<<< HEAD - struct i2c_msg xfer[2]; - int ret; - - reg = cpu_to_be16(reg); - - xfer[0].addr = i2c->addr; - xfer[0].flags = 0; - xfer[0].len = 2; - xfer[0].buf = (char *)® - - xfer[1].addr = i2c->addr; - xfer[1].flags = I2C_M_NOSTART; - xfer[1].len = bytes; - xfer[1].buf = (char *)src; - - ret = i2c_transfer(i2c->adapter, xfer, 2); - if (ret < 0) - return ret; - if (ret != 2) -======= unsigned char msg[bytes + 2]; int ret; @@ -84,7 +63,6 @@ static int wm831x_i2c_write_device(struct wm831x *wm831x, unsigned short reg, if (ret < 0) return ret; if (ret < bytes + 2) ->>>>>>> parent of 15f7fab... temp revert rk change return -EIO; return 0; @@ -94,19 +72,13 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm831x *wm831x; -<<<<<<< HEAD - -======= int ret,gpio,irq; ->>>>>>> parent of 15f7fab... temp revert rk change wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); if (wm831x == NULL) return -ENOMEM; i2c_set_clientdata(i2c, wm831x); -<<<<<<< HEAD -======= gpio = i2c->irq; ret = gpio_request(gpio, "wm831x"); @@ -121,17 +93,12 @@ static int wm831x_i2c_probe(struct i2c_client *i2c, } irq = gpio_to_irq(gpio); ->>>>>>> parent of 15f7fab... temp revert rk change wm831x->dev = &i2c->dev; wm831x->control_data = i2c; wm831x->read_dev = wm831x_i2c_read_device; wm831x->write_dev = wm831x_i2c_write_device; -<<<<<<< HEAD - return wm831x_device_init(wm831x, id->driver_data, i2c->irq); -======= return wm831x_device_init(wm831x, id->driver_data, irq); ->>>>>>> parent of 15f7fab... temp revert rk change } static int wm831x_i2c_remove(struct i2c_client *i2c) @@ -143,16 +110,16 @@ static int wm831x_i2c_remove(struct i2c_client *i2c) return 0; } -static int wm831x_i2c_suspend(struct device *dev) +static int wm831x_i2c_suspend(struct i2c_client *i2c, pm_message_t mesg) { - struct wm831x *wm831x = dev_get_drvdata(dev); + struct wm831x *wm831x = i2c_get_clientdata(i2c); return wm831x_device_suspend(wm831x); } -static int wm831x_i2c_resume(struct device *dev) +static int wm831x_i2c_resume(struct i2c_client *i2c) { - struct wm831x *wm831x = dev_get_drvdata(dev); + struct wm831x *wm831x = i2c_get_clientdata(i2c); int i; //set some intterupt again while resume for (i = 0; i < ARRAY_SIZE(wm831x->irq_masks_cur); i++) { @@ -184,24 +151,20 @@ static const struct i2c_device_id wm831x_i2c_id[] = { { "wm8320", WM8320 }, { "wm8321", WM8321 }, { "wm8325", WM8325 }, - { "wm8326", WM8326 }, { } }; MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id); -static const struct dev_pm_ops wm831x_pm_ops = { - .suspend = wm831x_i2c_suspend, - .resume = wm831x_i2c_resume, -}; static struct i2c_driver wm831x_i2c_driver = { .driver = { - .name = "wm831x", - .owner = THIS_MODULE, - .pm = &wm831x_pm_ops, + .name = "wm831x", + .owner = THIS_MODULE, }, .probe = wm831x_i2c_probe, .remove = wm831x_i2c_remove, + .suspend = wm831x_i2c_suspend, + .resume = wm831x_i2c_resume, .shutdown = wm831x_i2c_shutdown, .id_table = wm831x_i2c_id, }; @@ -209,7 +172,6 @@ static struct i2c_driver wm831x_i2c_driver = { static int __init wm831x_i2c_init(void) { int ret; - printk("%s \n", __FUNCTION__); ret = i2c_add_driver(&wm831x_i2c_driver); if (ret != 0) @@ -217,8 +179,9 @@ static int __init wm831x_i2c_init(void) return ret; } -subsys_initcall(wm831x_i2c_init); - +//subsys_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); diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index 5baffaaef70f..7070c3c916f5 100755 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c @@ -18,15 +18,13 @@ #include #include #include - +#include #include #include #include #include #include -<<<<<<< HEAD -======= #include /* * Since generic IRQs don't currently support interrupt controllers on @@ -37,7 +35,6 @@ * interrupts, but hopefully won't last too long. */ #define WM831X_IRQ_TYPE IRQF_TRIGGER_LOW ->>>>>>> parent of 15f7fab... temp revert rk change struct wm831x_irq_data { int primary; @@ -405,28 +402,13 @@ static void wm831x_irq_disable(struct irq_data *data) //printk("%s:irq=%d\n",__FUNCTION__,irq); } -static void wm831x_irq_disable(unsigned int irq) -{ - struct wm831x *wm831x = get_irq_chip_data(irq); - struct wm831x_irq_data *irq_data = irq_to_wm831x_irq(wm831x, irq); - - wm831x->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; - //printk("%s:irq=%d\n",__FUNCTION__,irq); -} - static int wm831x_irq_set_type(struct irq_data *data, unsigned int type) { struct wm831x *wm831x = irq_data_get_irq_chip_data(data); - int val, irq; + int val, irq = 0; -<<<<<<< HEAD irq = data->irq - wm831x->irq_base; - - if (irq < WM831X_IRQ_GPIO_1 || irq > WM831X_IRQ_GPIO_11) { -======= - irq = irq - wm831x->irq_base; if (irq < WM831X_IRQ_GPIO_1 || irq > WM831X_IRQ_GPIO_12) { ->>>>>>> parent of 15f7fab... temp revert rk change /* Ignore internal-only IRQs */ if (irq >= 0 && irq < WM831X_NUM_IRQS) return 0; @@ -452,17 +434,17 @@ static int wm831x_irq_set_type(struct irq_data *data, unsigned int type) WM831X_GPN_INT_MODE | WM831X_GPN_POL, val); } -static int wm831x_irq_set_wake(unsigned irq, unsigned state) +static int wm831x_irq_set_wake(struct irq_data *data, unsigned state) { - struct wm831x *wm831x = get_irq_chip_data(irq); - + struct wm831x *wm831x = irq_data_get_irq_chip_data(data); + int irq = data->irq; //only wm831x irq if ((irq > wm831x->irq_base + WM831X_IRQ_TEMP_THW) &&( irq < wm831x->irq_base + WM831X_NUM_IRQS)) { if(state) - wm831x_irq_unmask(irq); + wm831x_irq_enable(data); else - wm831x_irq_mask(irq); + wm831x_irq_disable(data); return 0; } else @@ -475,23 +457,13 @@ static int wm831x_irq_set_wake(unsigned irq, unsigned state) } static struct irq_chip wm831x_irq_chip = { -<<<<<<< HEAD .name = "wm831x", .irq_bus_lock = wm831x_irq_lock, .irq_bus_sync_unlock = wm831x_irq_sync_unlock, .irq_disable = wm831x_irq_disable, .irq_enable = wm831x_irq_enable, .irq_set_type = wm831x_irq_set_type, -======= - .name = "wm831x", - .bus_lock = wm831x_irq_lock, - .bus_sync_unlock = wm831x_irq_sync_unlock, - .disable = wm831x_irq_disable, - .mask = wm831x_irq_mask, - .unmask = wm831x_irq_unmask, - .set_type = wm831x_irq_set_type, - .set_wake = wm831x_irq_set_wake, ->>>>>>> parent of 15f7fab... temp revert rk change + .irq_set_wake = wm831x_irq_set_wake, }; #if WM831X_IRQ_LIST @@ -558,18 +530,6 @@ static void wm831x_irq_worker(struct work_struct *work) mutex_lock(&wm831x->irq_lock); - /* The touch interrupts are visible in the primary register as - * an optimisation; open code this to avoid complicating the - * main handling loop and so we can also skip iterating the - * descriptors. - */ - if (primary & WM831X_TCHPD_INT) - handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHPD); - if (primary & WM831X_TCHDATA_INT) - handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHDATA); - if (primary & (WM831X_TCHDATA_EINT | WM831X_TCHPD_EINT)) - goto out; - for (i = 0; i < ARRAY_SIZE(wm831x_irqs); i++) { int offset = wm831x_irqs[i].reg - 1; @@ -630,9 +590,6 @@ out_lock: mutex_unlock(&wm831x->irq_lock); out: - /* Touchscreen interrupts are handled specially in the driver */ - status_regs[0] &= ~(WM831X_TCHDATA_EINT | WM831X_TCHPD_EINT); - for (i = 0; i < ARRAY_SIZE(status_regs); i++) { if (status_regs[i]) wm831x_reg_write(wm831x, WM831X_INTERRUPT_STATUS_1 + i, @@ -695,33 +652,18 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) 0xffff); } + if (!irq) { + dev_warn(wm831x->dev, + "No interrupt specified - functionality limited\n"); + return 0; + } + if (!pdata || !pdata->irq_base) { dev_err(wm831x->dev, "No interrupt base specified, no interrupts\n"); return 0; } -<<<<<<< HEAD - if (pdata->irq_cmos) - i = 0; - else - i = WM831X_IRQ_OD; - - wm831x_set_bits(wm831x, WM831X_IRQ_CONFIG, - WM831X_IRQ_OD, i); - - /* Try to flag /IRQ as a wake source; there are a number of - * unconditional wake sources in the PMIC so this isn't - * conditional but we don't actually care *too* much if it - * fails. - */ - ret = enable_irq_wake(irq); - if (ret != 0) { - dev_warn(wm831x->dev, "Can't enable IRQ as wake source: %d\n", - ret); - } - -======= wm831x->irq_wq = create_singlethread_workqueue("wm831x-irq"); if (!wm831x->irq_wq) { dev_err(wm831x->dev, "Failed to allocate IRQ worker\n"); @@ -729,7 +671,6 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) } ->>>>>>> parent of 15f7fab... temp revert rk change wm831x->irq = irq; wm831x->flag_suspend = 0; wm831x->irq_base = pdata->irq_base; @@ -737,7 +678,7 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) wake_lock_init(&wm831x->irq_wake, WAKE_LOCK_SUSPEND, "wm831x_irq_wake"); wake_lock_init(&wm831x->handle_wake, WAKE_LOCK_SUSPEND, "wm831x_handle_wake"); #if WM831X_IRQ_LIST - wm831x->handle_wq = create_rt_workqueue("wm831x_handle_wq"); + wm831x->handle_wq = create_workqueue("wm831x_handle_wq"); if (!wm831x->handle_wq) { printk("cannot create workqueue\n"); return -EBUSY; @@ -764,25 +705,6 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) irq_set_noprobe(cur_irq); #endif } -<<<<<<< HEAD - - if (irq) { - ret = request_threaded_irq(irq, NULL, wm831x_irq_thread, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "wm831x", wm831x); - if (ret != 0) { - dev_err(wm831x->dev, "Failed to request IRQ %d: %d\n", - irq, ret); - return ret; - } - } else { - dev_warn(wm831x->dev, - "No interrupt specified - functionality limited\n"); - } - - - -======= #if (WM831X_IRQ_TYPE == IRQF_TRIGGER_LOW) ret = request_threaded_irq(wm831x->irq, wm831x_irq_thread, NULL, IRQF_TRIGGER_LOW| IRQF_ONESHOT,//IRQF_TRIGGER_FALLING, // @@ -799,7 +721,6 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) } enable_irq_wake(wm831x->irq); // so wm831x irq can wake up system ->>>>>>> parent of 15f7fab... temp revert rk change /* Enable top level interrupts, we mask at secondary level */ wm831x_reg_write(wm831x, WM831X_SYSTEM_INTERRUPTS_MASK, 0); diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c old mode 100644 new mode 100755 index 97c8dab6c954..5635be1c9622 --- a/drivers/mfd/wm831x-spi.c +++ b/drivers/mfd/wm831x-spi.c @@ -14,10 +14,10 @@ #include #include -#include #include #include + #include static int wm831x_spi_read_device(struct wm831x *wm831x, unsigned short reg, @@ -29,24 +29,14 @@ static int wm831x_spi_read_device(struct wm831x *wm831x, unsigned short reg, /* Go register at a time */ for (r = reg; r < reg + (bytes / 2); r++) { -<<<<<<< HEAD - tx_val = r | 0x8000; - -======= tx_val = cpu_to_be16(r | 0x8000); //printk("read:reg=0x%x,",reg); ->>>>>>> parent of 15f7fab... temp revert rk change ret = spi_write_then_read(wm831x->control_data, (u8 *)&tx_val, 2, (u8 *)d, 2); if (ret != 0) return ret; -<<<<<<< HEAD - - *d = be16_to_cpu(*d); -======= //printk("rec=0x%x\n",be16_to_cpu(*d)); //*d = be16_to_cpu(*d); ->>>>>>> parent of 15f7fab... temp revert rk change d++; } @@ -64,15 +54,9 @@ static int wm831x_spi_write_device(struct wm831x *wm831x, unsigned short reg, /* Go register at a time */ for (r = reg; r < reg + (bytes / 2); r++) { -<<<<<<< HEAD - data[0] = r; - data[1] = *s++; - -======= data[0] = cpu_to_be16(r); data[1] = *s++; //printk("write:reg=0x%x,send=0x%x\n",reg, data[0]); ->>>>>>> parent of 15f7fab... temp revert rk change ret = spi_write(spi, (char *)&data, sizeof(data)); if (ret != 0) return ret; @@ -85,12 +69,8 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) { struct wm831x *wm831x; enum wm831x_parent type; -<<<<<<< HEAD - -======= int ret,gpio,irq; ->>>>>>> parent of 15f7fab... temp revert rk change /* Currently SPI support for ID tables is unmerged, we're faking it */ if (strcmp(spi->modalias, "wm8310") == 0) type = WM8310; @@ -104,8 +84,6 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) type = WM8321; else if (strcmp(spi->modalias, "wm8325") == 0) type = WM8325; - else if (strcmp(spi->modalias, "wm8326") == 0) - type = WM8326; else { dev_err(&spi->dev, "Unknown device type\n"); return -EINVAL; @@ -118,8 +96,6 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) spi->bits_per_word = 16; spi->mode = SPI_MODE_0; -<<<<<<< HEAD -======= gpio = spi->irq; ret = gpio_request(gpio, "wm831x"); if (ret) { @@ -133,18 +109,13 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi) } irq = gpio_to_irq(gpio); ->>>>>>> parent of 15f7fab... temp revert rk change dev_set_drvdata(&spi->dev, wm831x); wm831x->dev = &spi->dev; wm831x->control_data = spi; wm831x->read_dev = wm831x_spi_read_device; wm831x->write_dev = wm831x_spi_write_device; -<<<<<<< HEAD - return wm831x_device_init(wm831x, type, spi->irq); -======= return wm831x_device_init(wm831x, type, irq); ->>>>>>> parent of 15f7fab... temp revert rk change } static int __devexit wm831x_spi_remove(struct spi_device *spi) @@ -156,31 +127,24 @@ static int __devexit wm831x_spi_remove(struct spi_device *spi) return 0; } -static int wm831x_spi_suspend(struct device *dev) +static int wm831x_spi_suspend(struct spi_device *spi, pm_message_t m) { - struct wm831x *wm831x = dev_get_drvdata(dev); - + struct wm831x *wm831x = dev_get_drvdata(&spi->dev); spin_lock(&wm831x->flag_lock); wm831x->flag_suspend = 1; spin_unlock(&wm831x->flag_lock); - return wm831x_device_suspend(wm831x); } -static const struct dev_pm_ops wm831x_spi_pm = { - .freeze = wm831x_spi_suspend, - .suspend = wm831x_spi_suspend, -}; - static struct spi_driver wm8310_spi_driver = { .driver = { .name = "wm8310", .bus = &spi_bus_type, .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, }, .probe = wm831x_spi_probe, .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, }; static struct spi_driver wm8311_spi_driver = { @@ -188,10 +152,10 @@ static struct spi_driver wm8311_spi_driver = { .name = "wm8311", .bus = &spi_bus_type, .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, }, .probe = wm831x_spi_probe, .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, }; static struct spi_driver wm8312_spi_driver = { @@ -199,10 +163,10 @@ static struct spi_driver wm8312_spi_driver = { .name = "wm8312", .bus = &spi_bus_type, .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, }, .probe = wm831x_spi_probe, .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, }; static struct spi_driver wm8320_spi_driver = { @@ -210,10 +174,10 @@ static struct spi_driver wm8320_spi_driver = { .name = "wm8320", .bus = &spi_bus_type, .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, }, .probe = wm831x_spi_probe, .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, }; static struct spi_driver wm8321_spi_driver = { @@ -221,10 +185,10 @@ static struct spi_driver wm8321_spi_driver = { .name = "wm8321", .bus = &spi_bus_type, .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, }, .probe = wm831x_spi_probe, .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, }; static struct spi_driver wm8325_spi_driver = { @@ -232,21 +196,10 @@ static struct spi_driver wm8325_spi_driver = { .name = "wm8325", .bus = &spi_bus_type, .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, - }, - .probe = wm831x_spi_probe, - .remove = __devexit_p(wm831x_spi_remove), -}; - -static struct spi_driver wm8326_spi_driver = { - .driver = { - .name = "wm8326", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - .pm = &wm831x_spi_pm, }, .probe = wm831x_spi_probe, .remove = __devexit_p(wm831x_spi_remove), + .suspend = wm831x_spi_suspend, }; static int __init wm831x_spi_init(void) @@ -277,17 +230,12 @@ static int __init wm831x_spi_init(void) if (ret != 0) pr_err("Failed to register WM8325 SPI driver: %d\n", ret); - ret = spi_register_driver(&wm8326_spi_driver); - if (ret != 0) - pr_err("Failed to register WM8326 SPI driver: %d\n", ret); - return 0; } subsys_initcall(wm831x_spi_init); static void __exit wm831x_spi_exit(void) { - spi_unregister_driver(&wm8326_spi_driver); spi_unregister_driver(&wm8325_spi_driver); spi_unregister_driver(&wm8321_spi_driver); spi_unregister_driver(&wm8320_spi_driver); diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index e198d40292e7..7ecd7de78c33 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -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, }, diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a9a94491b028..710153c51556 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -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" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index c4ed797a893b..3a67414ad023 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -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 diff --git a/drivers/misc/gps/rk29_gps.c b/drivers/misc/gps/rk29_gps.c index 0e4aa47e22ec..a9414f3fdd54 100755 --- a/drivers/misc/gps/rk29_gps.c +++ b/drivers/misc/gps/rk29_gps.c @@ -248,7 +248,7 @@ static struct file_operations rk29_gps_fops = { .owner = THIS_MODULE, .open = rk29_gps_open, .read = rk29_gps_read, - .ioctl = rk29_gps_ioctl, + .unlocked_ioctl = rk29_gps_ioctl, .release = rk29_gps_release, }; @@ -272,8 +272,8 @@ static int rk29_gps_probe(struct platform_device *pdev) return ret; } - init_MUTEX(&pdata->power_sem); - pdata->wq = create_freezeable_workqueue("rk29_gps"); + sema_init(&pdata->power_sem,1); + pdata->wq = create_freezable_workqueue("rk29_gps"); INIT_WORK(&pdata->work, rk29_gps_delay_power_downup); pdata->power_flag = 0; diff --git a/drivers/misc/mtk23d.c b/drivers/misc/mtk23d.c index 14fdcdbe50d2..8f8dae623395 100755 --- a/drivers/misc/mtk23d.c +++ b/drivers/misc/mtk23d.c @@ -23,6 +23,7 @@ #include #include #include "../mtd/rknand/api_flash.h" +#include MODULE_LICENSE("GPL"); @@ -290,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"); @@ -302,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; } @@ -405,7 +406,7 @@ static struct file_operations mtk23d_fops = { .owner = THIS_MODULE, .open = mtk23d_open, .release = mtk23d_release, - .ioctl = mtk23d_ioctl + .unlocked_ioctl = mtk23d_ioctl }; static struct miscdevice mtk23d_misc = { @@ -423,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) @@ -492,7 +494,7 @@ static int mtk23d_probe(struct platform_device *pdev) #endif INIT_WORK(&mt6223d_data->work, bpwakeup_work_func_work); - init_MUTEX(&pdata->power_sem); + sema_init(&pdata->power_sem,1); power_on = 1; result = misc_register(&mtk23d_misc); if(result) diff --git a/drivers/misc/sc8800.c b/drivers/misc/sc8800.c new file mode 100755 index 000000000000..c8d26fed579d --- /dev/null +++ b/drivers/misc/sc8800.c @@ -0,0 +1,728 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 index 000000000000..d30d82ccb17a --- /dev/null +++ b/drivers/misc/tdsc8800.c @@ -0,0 +1,179 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +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); diff --git a/drivers/mmc/host/rk29_sdmmc.c b/drivers/mmc/host/rk29_sdmmc.c index ae92103ddb65..7d2e6c01df7d 100755 --- a/drivers/mmc/host/rk29_sdmmc.c +++ b/drivers/mmc/host/rk29_sdmmc.c @@ -696,7 +696,7 @@ void rk29_sdmmc_set_frq(struct rk29_sdmmc *host) card = (struct mmc_card *)mmchost->card; ios = ( struct mmc_ios *)&mmchost->ios; - if(!card && !ios) + if(!card || !ios) return; if(MMC_POWER_ON == ios->power_mode) diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index 991df931d4aa..3027be6e850c 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -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 index 8782b4483bd6..000000000000 --- a/drivers/net/wireless/bcm4319/ChangeLog.txt +++ /dev/null @@ -1,54 +0,0 @@ -=========================================================================== -=== Version 1.05 @ 2011-03-26 === -=========================================================================== - -1. ½â¾öÁËÉî¶È˯Ãß15·ÖÖÓºó»½ÐÑÒì³£µÄÎÊÌâ -2. ¿ªÆôCombo-SCANÒÔÖ§³Öwpa_supplicant_6 - -=========================================================================== -=== Version 1.04 @ 2011-03-21 === -=========================================================================== - -1. ½â¾öÁ˲»ÄÜÕý³£Á¬½ÓAPµÄÎÊÌâ - -=========================================================================== -=== Version 1.03 @ 2011-01-24 === -=========================================================================== - -1. Ìí¼Ó¶ÔRK29ƽ̨µÄÖ§³Ö¡£ - -=========================================================================== -=== Version 1.02 @ 20101102 === -=========================================================================== - -1. ÔÚɨÃèÁбíÖУ¬ÓÐһЩAP¼´Ê¹½Ï½ü£¬ÈÔÈ»»áËÑË÷²»µ½¡£ - =>½«tplinklai¸ÄΪͨµÀ13ºó£¬ÈÔÈ»ÕÒ²»µ½Ëü¡£ - =>·¢ÏÖµ±Ç°µÄ¹¤×÷ģʽÖУ¬Ö»Ö§³ÖɨÃ赽ͨµÀ11¡£ - =>dhd_preinit_ioctlsº¯ÊýÖÐÌí¼ÓÈçϺ¯Êý£º - dhdcdc_query_ioctl(dhd, 0, WLC_GET_COUNTRY, - dhd->country_code, sizeof(dhd->country_code)); - ·¢ÏÖĿǰģ×éĬÈϵÄCOUNTRY CODEÊÇUS£¬¶øUSÖÐÊÇÖ»Ö§³Ö11¸öͨµÀµÄ¡£ - => -=========================================================================== -=== Version 1.01 @ 20101027 === -=========================================================================== - -1. ¸ÄΪʹÓÃwifi_version.hÖеİ汾¶¨Òå¡£ - -2. ͨ¹ýÔÚ°åÉÏnetperf -H 192.168.1.200 -t TCP_STREAM½øÐвâÊÔ£¬»á³öÏÖ£º - [204] dhd_bus_txdata: out of bus->txq !!! - [204] dhd_bus_txdata: out of bus->txq !!! - [205] CMD: 53 FAIL raw_ints: 12034 masked ints: 4 - [207] CMD: 52 FAIL raw_ints: 11030 masked ints: 1000 - [207] CMD: 52 FAIL raw_ints: 11030 masked ints: 1000 - [207] CMD: 52 FAIL raw_ints: 11030 masked ints: 1000 - [207] CMD: 52 FAIL raw_ints: 11030 masked ints: 1000 - [207] CMD: 52 FAIL raw_ints: 11030 masked ints: 1000 - - ÊÖ¶¯ÅäÖÃÃüÁ - iwconfig wlan0 mode managed - iwconfig wlan0 essid tplinklai - ifconfig wlan0 192.168.1.21 - netperf -H 192.168.1.200 -t TCP_STREAM - - ÔÚSDIOÇý¶¯ÖУ¬´ò¿ªDATA BUSYµÄ¼ì²â£¬ÔòûÓгöÏÖÎÊÌâ¡£ diff --git a/drivers/net/wireless/bcm4319/Kconfig b/drivers/net/wireless/bcm4319/Kconfig deleted file mode 100644 index 11aafd3898c6..000000000000 --- a/drivers/net/wireless/bcm4319/Kconfig +++ /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 index 11aafd3898c6..000000000000 --- a/drivers/net/wireless/bcm4319/Kconfig.bcm4319 +++ /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/Makefile b/drivers/net/wireless/bcm4319/Makefile index 3c7768f6d734..3d9df6a001e2 100644 --- a/drivers/net/wireless/bcm4319/Makefile +++ b/drivers/net/wireless/bcm4319/Makefile @@ -1,42 +1,24 @@ +# 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 -RKWLCFGDIR = ../wifi_power -BROADCOM_SRC_DIR = drivers/net/wireless/bcm4319 +#options defines dependent on platform board and applicantion requirements: +#-DOOB_INTR_ONLY -DMMC_SDIO_ABORT -DHW_OOB -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 +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 - -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 - - - - +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 index 97a3655ffbf4..000000000000 --- a/drivers/net/wireless/bcm4319/Makefile.bcm4319 +++ /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 - - diff --git a/drivers/net/wireless/bcm4319/bcmpcispi.c b/drivers/net/wireless/bcm4319/bcmpcispi.c index c0a66f1aa3e4..1a8b6717f924 100644 --- a/drivers/net/wireless/bcm4319/bcmpcispi.c +++ b/drivers/net/wireless/bcm4319/bcmpcispi.c @@ -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 @@ -606,18 +606,23 @@ spi_spinbits(sdioh_info_t *sd) spin_count = 0; while ((SPIPCI_RREG(sd->osh, ®s->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, ®s->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++; diff --git a/drivers/net/wireless/bcm4319/bcmsdh_linux.c b/drivers/net/wireless/bcm4319/bcmsdh_linux.c index e6241cc4bc59..cdb2c5e1f1ec 100644 --- a/drivers/net/wireless/bcm4319/bcmsdh_linux.c +++ b/drivers/net/wireless/bcm4319/bcmsdh_linux.c @@ -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__)); +/* Example of HW_OOB for HW2: please refer to your host specifiction */ +/* sdhcinfo->oob_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE; */ + dev_set_drvdata(sdhcinfo->dev, dhdp); + 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; - /* 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 */ diff --git a/drivers/net/wireless/bcm4319/bcmsdh_sdmmc.c b/drivers/net/wireless/bcm4319/bcmsdh_sdmmc.c index 7948bbe97d2e..031367b8f18f 100644 --- a/drivers/net/wireless/bcm4319/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/bcm4319/bcmsdh_sdmmc.c @@ -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 @@ -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]); diff --git a/drivers/net/wireless/bcm4319/bcmsdh_sdmmc_linux.c b/drivers/net/wireless/bcm4319/bcmsdh_sdmmc_linux.c index f52207e3225a..8992a4267f9f 100644 --- a/drivers/net/wireless/bcm4319/bcmsdh_sdmmc_linux.c +++ b/drivers/net/wireless/bcm4319/bcmsdh_sdmmc_linux.c @@ -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 @@ -34,15 +34,20 @@ #include #include -#include #include #include #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 @@ -51,15 +56,10 @@ #define SDIO_DEVICE_ID_BROADCOM_4319 0x4319 #endif /* !defined(SDIO_DEVICE_ID_BROADCOM_4329) */ - #include #include - -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; } diff --git a/drivers/net/wireless/bcm4319/bcmsdstd.c b/drivers/net/wireless/bcm4319/bcmsdstd.c index 0b1b575d9629..0ca1f8ff8a24 100644 --- a/drivers/net/wireless/bcm4319/bcmsdstd.c +++ b/drivers/net/wireless/bcm4319/bcmsdstd.c @@ -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 @@ -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; diff --git a/drivers/net/wireless/bcm4319/bcmsdstd_linux.c b/drivers/net/wireless/bcm4319/bcmsdstd_linux.c index ad6d6603fccd..a8b98e2054a0 100644 --- a/drivers/net/wireless/bcm4319/bcmsdstd_linux.c +++ b/drivers/net/wireless/bcm4319/bcmsdstd_linux.c @@ -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 @@ -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 index 000000000000..0f131a40f4b8 --- /dev/null +++ b/drivers/net/wireless/bcm4319/bcmspibrcm.c @@ -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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* bcmsdh to/from specific controller APIs */ +#include /* ioctl/iovars */ +#include + +#include + + +#include +#include + +#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, ®)) != + 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, ®)) != + 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, ®data)) != 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, ®data); \ + 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, ®data); \ + 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, ®data); + 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, ®data)) != + 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, ®data)) != 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, + ®data)) != 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, ®data)) != 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, ®data)) != 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, ®data)) != 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, ®data)) != 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); +} diff --git a/drivers/net/wireless/bcm4319/dhd.h b/drivers/net/wireless/bcm4319/dhd.h index 09da65c51c31..dca30396a4e6 100644 --- a/drivers/net/wireless/bcm4319/dhd.h +++ b/drivers/net/wireless/bcm4319/dhd.h @@ -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 -#endif #include #include #include @@ -47,11 +44,10 @@ #include #include #include +#include #include #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK) -#include -#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */ + /* The kernel threading is sdio-specific */ #else /* LINUX */ #define ENOMEM 1 @@ -64,6 +60,11 @@ #include +#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_ */ diff --git a/drivers/net/wireless/bcm4319/dhd_bus.h b/drivers/net/wireless/bcm4319/dhd_bus.h index 9e29fb955444..97af41b313d0 100644 --- a/drivers/net/wireless/bcm4319/dhd_bus.h +++ b/drivers/net/wireless/bcm4319/dhd_bus.h @@ -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); diff --git a/drivers/net/wireless/bcm4319/dhd_cdc.c b/drivers/net/wireless/bcm4319/dhd_cdc.c index 3abfbf820368..a68ad61c58b4 100644 --- a/drivers/net/wireless/bcm4319/dhd_cdc.c +++ b/drivers/net/wireless/bcm4319/dhd_cdc.c @@ -40,13 +40,11 @@ #include #include #include -#ifdef CUSTOMER_HW2 -int wifi_get_mac_addr(unsigned char *buf); -#endif + +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 #define DHD_SDALIGN 32 @@ -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); diff --git a/drivers/net/wireless/bcm4319/dhd_common.c b/drivers/net/wireless/bcm4319/dhd_common.c index 3800c3d7d2de..946ff3f8166b 100644 --- a/drivers/net/wireless/bcm4319/dhd_common.c +++ b/drivers/net/wireless/bcm4319/dhd_common.c @@ -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 #include @@ -37,15 +37,23 @@ #include #include - #include +#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 +#include +#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 -#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 diff --git a/drivers/net/wireless/bcm4319/dhd_custom_gpio.c b/drivers/net/wireless/bcm4319/dhd_custom_gpio.c index d4d7e06b3f65..8c6ec470b8bd 100644 --- a/drivers/net/wireless/bcm4319/dhd_custom_gpio.c +++ b/drivers/net/wireless/bcm4319/dhd_custom_gpio.c @@ -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 #include -#include -#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 */ diff --git a/drivers/net/wireless/bcm4319/dhd_dbg.h b/drivers/net/wireless/bcm4319/dhd_dbg.h index 9f09ce7fcc04..b48c1d70f144 100644 --- a/drivers/net/wireless/bcm4319/dhd_dbg.h +++ b/drivers/net/wireless/bcm4319/dhd_dbg.h @@ -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) diff --git a/drivers/net/wireless/bcm4319/dhd_linux.c b/drivers/net/wireless/bcm4319/dhd_linux.c index 275407f5ae06..81eef135a16d 100644 --- a/drivers/net/wireless/bcm4319/dhd_linux.c +++ b/drivers/net/wireless/bcm4319/dhd_linux.c @@ -22,11 +22,10 @@ * 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 #endif #include @@ -48,6 +47,7 @@ #include #include +#include #include #include #include @@ -58,13 +58,149 @@ #include #include #include +#include +#ifdef CONFIG_HAS_WAKELOCK +#include +#endif +#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) +//#include +#include -#include -#include -#include -#include +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); +} + +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 @@ -92,12 +228,16 @@ print_tainted() #include #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 -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; + + 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 +} + #if defined(CONFIG_HAS_EARLYSUSPEND) - -int dhd_set_suspend(int value, dhd_pub_t *dhd) +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->dpc_pid >= 0) - { - KILL_PROC(dhd->dpc_pid, SIGTERM); - wait_for_completion(&dhd->dpc_exited); - } - else - tasklet_kill(&dhd->tasklet); + dhd_bus_detach(dhdp); - if (dhd->sysioc_pid >= 0) { - KILL_PROC(dhd->sysioc_pid, SIGTERM); - wait_for_completion(&dhd->sysioc_exited); - } + if (dhdp->prot) + dhd_prot_detach(dhdp); - dhd_bus_detach(dhdp); - - if (dhdp->prot) - dhd_prot_detach(dhdp); - -#if defined(CONFIG_WIRELESS_EXT) - /* Attach and link in the iw */ - wl_iw_detach(); -#endif - - -#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,220 +2604,30 @@ 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; + + return error; } -//hojie: 2010.10.11 -//for wifi power control - -//#if (ANDROID_POWER_SAVE == 1) -#if 0 -//#include -//#include -//android_suspend_lock_t wifi_android_lock; - -/* - * Suspend request from android power manager. - */ -int wifi_suspend(suspend_state_t state) -{ - 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; - } -*/ -} - - -void wifi_resume(void) -{ - printk("Android want wifi to be resumed.\n"); -} - -#endif //(ANDROID_POWER_SAVE == 1) - -//#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); - +//module_init(dhd_module_init); +//module_exit(dhd_module_cleanup); int mv88w8686_if_sdio_init_module(void) { return rockchip_wifi_init_module(); @@ -2575,30 +2635,15 @@ int mv88w8686_if_sdio_init_module(void) void mv88w8686_if_sdio_exit_module(void) { - rockchip_wifi_exit_module(); + rockchip_wifi_exit_module(); } +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); -#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 */ @@ -2608,9 +2653,10 @@ 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; + + flags = dhd_os_spin_lock(pub); /* 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); - - /* 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 { + 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); - - /* Turning on watchdog back */ - if (!flag) - dhd_os_wd_timer(&dhd->pub, dhd_watchdog_ms); - DHD_ERROR(("%s: WLAN OFF DONE\n", __FUNCTION__)); - - return 1; + return ret; } +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; + + 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); +} diff --git a/drivers/net/wireless/bcm4319/dhd_proto.h b/drivers/net/wireless/bcm4319/dhd_proto.h index 382785a1ff6b..7ef6929a5bf7 100644 --- a/drivers/net/wireless/bcm4319/dhd_proto.h +++ b/drivers/net/wireless/bcm4319/dhd_proto.h @@ -34,7 +34,7 @@ #include #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 diff --git a/drivers/net/wireless/bcm4319/dhd_sdio.c b/drivers/net/wireless/bcm4319/dhd_sdio.c index cac624a918b6..78dff1c489b8 100644 --- a/drivers/net/wireless/bcm4319/dhd_sdio.c +++ b/drivers/net/wireless/bcm4319/dhd_sdio.c @@ -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 @@ -36,17 +36,11 @@ #include #include #include - #include #include #include -#ifdef DHD_DEBUG -#include -#include -#endif /* DHD_DEBUG */ #include #include - #include #include #include @@ -64,9 +58,12 @@ #include #include -#ifndef DHDSDIO_MEM_DUMP_FNAME -#define DHDSDIO_MEM_DUMP_FNAME "mem_dump" -#endif +#ifdef DHD_DEBUG +#include +#endif /* DHD_DEBUG */ +#ifdef DHD_DEBUG_TRAP +#include +#endif /* DHD_DEBUG_TRAP */ #define QLEN 256 /* bulk rx and tx queue lengths */ #define FCHI (QLEN - 10) @@ -127,11 +124,11 @@ /* 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 */ @@ -149,6 +146,8 @@ 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 index 452ea8f5bcb8..000000000000 --- a/drivers/net/wireless/bcm4319/firmware/nvram_4319_201008.txt +++ /dev/null @@ -1,49 +0,0 @@ -# bcm94319wlusbn4l board -# $Copyright (C) 2008 Broadcom Corporation$ -# $Id: bcm94319lcsdn4l.txt,v 1.18 2009/11/11 17:44:06 jayaramn Exp $ - -sromrev=3 -vendid=0x14e4 -devid=0x4338 - -boardtype=0x507 -boardrev=0x1402 -boardflags=0x02000200 - -# On board crystal frequency in KHz -xtalfreq=30000 - -aa2g=1 -aa5g=0 -ag0=3 - -ccode=ww -regrev=5 -opo=0 -pa0b0=0x15E0 -pa0b1=0xFAC6 -pa0b2=0xFEC3 -pa0itssit=62 -pa0maxpwr=74 - -rssismf2g=0xa -rssismc2g=0xb -rssisav2g=0x3 -bxa2g=0 -tri2g=0x6B -cckdigfilttype=3 -rxpo2g=2 - -cckpo=0 -ofdmpo=0x44444444 -mcs2gpo0=0x6666 -mcs2gpo1=0x6666 -mcs2gpo2=0x0000 -mcs2gpo3=0x0000 -mcs2gpo4=0x6666 -mcs2gpo5=0x6666 -boardnum=1 -macaddr=00:90:4c:14:43:19 - -#for mfgc -otpimagesize=182 diff --git a/drivers/net/wireless/bcm4319/include/bcmdefs.h b/drivers/net/wireless/bcm4319/include/bcmdefs.h index e3c6876f86fa..f4e99461971b 100644 --- a/drivers/net/wireless/bcm4319/include/bcmdefs.h +++ b/drivers/net/wireless/bcm4319/include/bcmdefs.h @@ -29,7 +29,6 @@ #define STATIC static - #define SI_BUS 0 #define PCI_BUS 1 #define PCMCIA_BUS 2 diff --git a/drivers/net/wireless/bcm4319/include/bcmsdh_sdmmc.h b/drivers/net/wireless/bcm4319/include/bcmsdh_sdmmc.h index 6ec5874b6187..4e6d1b5bd94f 100644 --- a/drivers/net/wireless/bcm4319/include/bcmsdh_sdmmc.h +++ b/drivers/net/wireless/bcm4319/include/bcmsdh_sdmmc.h @@ -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 index 000000000000..9dce878d11e2 --- /dev/null +++ b/drivers/net/wireless/bcm4319/include/bcmspibrcm.h @@ -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 diff --git a/drivers/net/wireless/bcm4319/include/epivers.h b/drivers/net/wireless/bcm4319/include/epivers.h index 114c735fb381..23ee514a7b6b 100644 --- a/drivers/net/wireless/bcm4319/include/epivers.h +++ b/drivers/net/wireless/bcm4319/include/epivers.h @@ -31,18 +31,18 @@ #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 diff --git a/drivers/net/wireless/bcm4319/include/linuxver.h b/drivers/net/wireless/bcm4319/include/linuxver.h index 6ee5c5872f61..6ed22658a72b 100644 --- a/drivers/net/wireless/bcm4319/include/linuxver.h +++ b/drivers/net/wireless/bcm4319/include/linuxver.h @@ -32,13 +32,9 @@ #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) #include -#else -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)) -#include -#else +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)) #include #endif -#endif #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)) @@ -70,6 +66,7 @@ #include #include #include +#include #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 diff --git a/drivers/net/wireless/bcm4319/include/proto/bcmevent.h b/drivers/net/wireless/bcm4319/include/proto/bcmevent.h index 46c04d379227..1f8ecb14d97a 100644 --- a/drivers/net/wireless/bcm4319/include/proto/bcmevent.h +++ b/drivers/net/wireless/bcm4319/include/proto/bcmevent.h @@ -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 diff --git a/drivers/net/wireless/bcm4319/include/sbchipc.h b/drivers/net/wireless/bcm4319/include/sbchipc.h index 05b3fd872973..39e5c8d6aed0 100644 --- a/drivers/net/wireless/bcm4319/include/sbchipc.h +++ b/drivers/net/wireless/bcm4319/include/sbchipc.h @@ -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 index 000000000000..c740296de9af --- /dev/null +++ b/drivers/net/wireless/bcm4319/include/spid.h @@ -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 index 000000000000..b3ccd7249dcc --- /dev/null +++ b/drivers/net/wireless/bcm4319/include/wifi_version.h @@ -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 */ diff --git a/drivers/net/wireless/bcm4319/include/wlioctl.h b/drivers/net/wireless/bcm4319/include/wlioctl.h index d346945dec94..cd7725a70db4 100644 --- a/drivers/net/wireless/bcm4319/include/wlioctl.h +++ b/drivers/net/wireless/bcm4319/include/wlioctl.h @@ -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; diff --git a/drivers/net/wireless/bcm4319/linux_osl.c b/drivers/net/wireless/bcm4319/linux_osl.c index 242af39e0caa..980416baf918 100644 --- a/drivers/net/wireless/bcm4319/linux_osl.c +++ b/drivers/net/wireless/bcm4319/linux_osl.c @@ -26,9 +26,7 @@ #define LINUX_OSL -#if defined(CHROMIUMOS_COMPAT_WIRELESS) -#include -#endif + #include #include #include @@ -37,6 +35,7 @@ #include #include #include +#include #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 index 2fcad1b938ed..000000000000 --- a/drivers/net/wireless/bcm4319/mkclean.sh +++ /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 index 224f9148b3dd..000000000000 --- a/drivers/net/wireless/bcm4319/mkpkg.sh +++ /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" diff --git a/drivers/net/wireless/bcm4319/wl_cfg80211.c b/drivers/net/wireless/bcm4319/wl_cfg80211.c index 03439718beea..81491cb97746 100644 --- a/drivers/net/wireless/bcm4319/wl_cfg80211.c +++ b/drivers/net/wireless/bcm4319/wl_cfg80211.c @@ -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; diff --git a/drivers/net/wireless/bcm4319/wl_iw.c b/drivers/net/wireless/bcm4319/wl_iw.c index c25cf2c8e38f..146dffd52976 100644 --- a/drivers/net/wireless/bcm4319/wl_iw.c +++ b/drivers/net/wireless/bcm4319/wl_iw.c @@ -21,10 +21,9 @@ * 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 #include #include @@ -49,15 +48,17 @@ typedef const struct si_pub si_t; #include #include #include -#include -#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 +#include + #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 +#include #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 #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)); + + 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__)); + /* 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 *)®addr, (char *)&saved_reg50); + regaddr = 51; + dev_wlc_intvar_set_reg(dev, "btc_params", + (char *)®addr, (char *)&saved_reg51); + regaddr = 64; + dev_wlc_intvar_set_reg(dev, "btc_params", + (char *)®addr, (char *)&saved_reg64); + regaddr = 65; + dev_wlc_intvar_set_reg(dev, "btc_params", + (char *)®addr, (char *)&saved_reg65); + regaddr = 71; + dev_wlc_intvar_set_reg(dev, "btc_params", + (char *)®addr, (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 *)®addr, (char *)&saved_reg66); @@ -817,12 +1022,15 @@ wl_iw_set_btcoex_dhcp( regaddr = 68; dev_wlc_intvar_set_reg(dev, "btc_params", \ (char *)®addr, (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,6 +1132,91 @@ wl_iw_get_link_speed( wrqu->data.length = p - extra + 1; + net_os_wake_unlock(dev); + return error; +} + + +static int +wl_iw_get_dtim_skip( + struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, + char *extra +) +{ + int error = -1; + char *p = extra; + char iovbuf[32]; + + net_os_wake_lock(dev); + if (g_onoff == G_WLAN_SET_ON) { + + memset(iovbuf, 0, sizeof(iovbuf)); + strcpy(iovbuf, "bcn_li_dtim"); + + 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_dtim_skip( + struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, + char *extra +) +{ + int error = -1; + char *p = extra; + int bcn_li_dtim; + char iovbuf[32]; + + net_os_wake_lock(dev); + if (g_onoff == G_WLAN_SET_ON) { + + bcn_li_dtim = htod32((uint)*(extra + strlen(DTIM_SKIP_SET_CMD) + 1) - '0'); + + if ((bcn_li_dtim >= 0) || ((bcn_li_dtim <= 5))) { + + 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"); + + 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 dtim_skip %d failed code %d\n", \ + __FUNCTION__, bcn_li_dtim, error)); + } + 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; } @@ -894,6 +1233,8 @@ wl_iw_get_band( char *p = extra; static int band; + net_os_wake_lock(dev); + if (g_onoff == G_WLAN_SET_ON) { error = dev_wlc_ioctl(dev, WLC_GET_BAND, &band, sizeof(band)); @@ -901,6 +1242,8 @@ wl_iw_get_band( wrqu->data.length = p - extra + 1; } + + net_os_wake_unlock(dev); return error; } @@ -915,34 +1258,214 @@ wl_iw_set_band( { int error = -1; char *p = extra; - char band; + uint band; + + net_os_wake_lock(dev); if (g_onoff == G_WLAN_SET_ON) { - band = *(extra + strlen(BAND_SET_CMD) + 1) - '0'; + 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__, \ + else WL_ERROR(("%s: set band %d failed code %d\n", __FUNCTION__, \ band, error)); } - else WL_ERROR(("%s Incorrect band setting, ignored\n", __FUNCTION__)); + 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( @@ -959,21 +1482,35 @@ wl_iw_get_rssi( 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)); - rssi = dtoh32(scb_val.val); + 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)); - - ssid.SSID_len = dtoh32(ssid.SSID_len); + 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_format_ssid(ssidbuf, ssid.SSID, dtoh32(ssid.SSID_len)); - p += snprintf(p, MAX_WX_STRING, "%s rssi %d ", ssidbuf, rssi); + 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; } @@ -995,6 +1532,7 @@ wl_iw_send_priv_event( 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); + sdioh_start(NULL, 1); #endif - - dhd_dev_init_ioctl(dev); -#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); - ret |= get_parmeter_from_string(&str_ptr, "MAX_SCB=", PTYPE_INTDEC, &ap_cfg->max_scb, 5); + 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; + } - 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; + rssi = dtoh32(scb_val.val); + p_mac_str += snprintf(p_mac_str, MAX_WX_STRING, + "RSSI:%d", rssi); } } - WL_ERROR(("Exited %s \n", __FUNCTION__)); + p_iwrq->data.length = strlen(mac_lst) + 1; + + 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) { + bcopy(mac_lst, extra, p_iwrq->data.length); + } + +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; @@ -1718,56 +2254,6 @@ wl_iw_get_mode( 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, @@ -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)); + 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_TRACE(("results->buflen = %d\n", results->buflen)); - status = dtoh32(list_buf->status); - MUTEX_UNLOCK_WL_SCAN_SET(); + 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) + memset(&wrqu, 0, sizeof(wrqu)); + + wireless_send_event(iscan->dev, SIOCGIWSCAN, &wrqu, NULL); +#if defined(CONFIG_FIRST_SCAN) 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 + 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, ðer_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 *)¶mval, 1); + if ((error = dev_wlc_bufvar_set(dev, "tkip_countermeasures", \ + (char *)¶mval, 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 *)¶mval, 1); + error = dev_wlc_bufvar_set(dev, "wsec_restrict", \ + (char *)¶mval, 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 *)¶mval, 1); + error = dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", \ + (char *)¶mval, 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 *)¶mval, 1); + error = dev_wlc_bufvar_get(dev, "tkip_countermeasures", \ + (char *)¶mval, 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 *)¶mval, 1); + error = dev_wlc_bufvar_get(dev, "wsec_restrict", \ + (char *)¶mval, 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 *)¶mval, 1); + error = dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", \ + (char *)¶mval, 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:"; - int8* p; + 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)); + 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")); + } - } 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++) + ioc_res = dev_wlc_ioctl(dev, WLC_SET_MACMODE, &mac_mode, sizeof(mac_mode)); + check_error(ioc_res, "ioctl ERROR:", __FUNCTION__, __LINE__); + + length = sizeof(maclist->count) + maclist->count*ETHER_ADDR_LEN; + dev_wlc_ioctl(dev, WLC_SET_MACLIST, maclist, length); + + 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, 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])); + 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])); - - bcopy(black_maclist, &ap_black_list, sizeof(ap_black_list)); + 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)); - 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; + 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 +#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; +} + +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 (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, "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 (strnicmp(extra, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) { + if (g_onoff == G_WLAN_SET_OFF) { + 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) { #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 + 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")); + 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 - } diff --git a/drivers/net/wireless/bcm4319/wl_iw.h b/drivers/net/wireless/bcm4319/wl_iw.h index 12c7c19d5d78..928291fe589a 100644 --- a/drivers/net/wireless/bcm4319/wl_iw.h +++ b/drivers/net/wireless/bcm4319/wl_iw.h @@ -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 $ */ @@ -43,27 +43,42 @@ #define GET_HOME_DWELL "HOME=" #define GET_SCAN_TYPE "TYPE=" -#define BAND_GET_CMD "BANDGET" -#define BAND_SET_CMD "BANDSET" +#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" -#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) +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) @@ -73,12 +88,13 @@ #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 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 index 2bc03de3e7a5..000000000000 --- a/drivers/net/wireless/bcm4319/wl_iw_dbg.c +++ /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 - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include - -typedef void wlc_info_t; -typedef void wl_info_t; -typedef const struct si_pub si_t; -#include - -#include -#include -#include -#include -#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 - -#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 - -#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 -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 -#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 *)(®), 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 *)®_addr[0], (char *)addr, 4); - memcpy((char *)®_addr[4], (char *)val, 4); - - return (dev_wlc_bufvar_set(dev, name, (char *)®_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 *)®addr, (char *)&saved_reg66); - regaddr = 41; - dev_wlc_intvar_set_reg(dev, "btc_params", \ - (char *)®addr, (char *)&saved_reg41); - regaddr = 68; - dev_wlc_intvar_set_reg(dev, "btc_params", \ - (char *)®addr, (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(¶ms->bssid, ðer_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(¶ms->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 *)¶mval, 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 *)¶mval, 1); - break; - - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - dev_wlc_bufvar_set(dev, "rx_unencrypted_eapol", (char *)¶mval, 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 *)¶mval, 1); - break; - - case IW_AUTH_DROP_UNENCRYPTED: - dev_wlc_bufvar_get(dev, "wsec_restrict", (char *)¶mval, 1); - break; - - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - dev_wlc_bufvar_get(dev, "rx_unencrypted_eapol", (char *)¶mval, 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 - -} diff --git a/drivers/net/wireless/rtl8192c/Kconfig b/drivers/net/wireless/rtl8192c/Kconfig index bee5ed626452..a0f326be561e 100755 --- a/drivers/net/wireless/rtl8192c/Kconfig +++ b/drivers/net/wireless/rtl8192c/Kconfig @@ -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 diff --git a/drivers/net/wireless/rtl8192c/core/rtw_ioctl_set.uu b/drivers/net/wireless/rtl8192c/core/rtw_ioctl_set.uu index 6d0fe423d5ed..d5e0ce29cbf6 100644 --- a/drivers/net/wireless/rtl8192c/core/rtw_ioctl_set.uu +++ b/drivers/net/wireless/rtl8192c/core/rtw_ioctl_set.uu @@ -1,170 +1,169 @@ 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@,$/B4-$=+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#,#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#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#`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#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!@` -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='=?'0`+F1A=&$`+F)S -M@````,``'`````` -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````$````"0!R -M='=?0!R='=? -M`P``!PL``",#```'"T``)0,```< -M+@``P`P``!P:``#8#```'"(``.@,```<,@``$`T``!PJ```@#0``'#L``#`- -M```"%@``-`T```(4``#4#0``'"@``!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#4$((/E +M7SV@XP-@A.<$`*#A7AV$XC@0@>(&(*#A`3"@X_[__^L`0%#B`4"@$P0`H.%P +M@+WH\$(`0*#A`5"@X00PD>4``%/C`@``N@$!$^,N```*00$`Z@$! +M$^,K```*5PV`XB@`@.+@$(3B_O__ZP!@4.($```*N#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'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"XP,PU>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`6UT86(` +M+G-T'1A8@`N&ED>``N#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@$`````````````$````%@$``$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?0!R='=?7!R:79?9&5V7VYE='=O``#<````'!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````@``!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+```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)); diff --git a/drivers/net/wireless/rtl8192c/include/autoconf.h b/drivers/net/wireless/rtl8192c/include/autoconf.h index 6b6e6caae14b..ff29e0a94223 100755 --- a/drivers/net/wireless/rtl8192c/include/autoconf.h +++ b/drivers/net/wireless/rtl8192c/include/autoconf.h @@ -131,7 +131,7 @@ /* * 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 /* diff --git a/drivers/net/wireless/rtl8192c/include/osdep_service.h b/drivers/net/wireless/rtl8192c/include/osdep_service.h index 8450b03d6bc6..1f9ea8bd2cb6 100755 --- a/drivers/net/wireless/rtl8192c/include/osdep_service.h +++ b/drivers/net/wireless/rtl8192c/include/osdep_service.h @@ -47,7 +47,7 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,5)) #include #endif - #include +// #include #include #include #include diff --git a/drivers/net/wireless/rtl8192c/include/rtw_io.h b/drivers/net/wireless/rtl8192c/include/rtw_io.h index 50226122c485..0bc5383d2e10 100755 --- a/drivers/net/wireless/rtl8192c/include/rtw_io.h +++ b/drivers/net/wireless/rtl8192c/include/rtw_io.h @@ -33,7 +33,7 @@ #include #endif #include -#include +//#include #include #include diff --git a/drivers/net/wireless/rtl8192c/os_dep/linux/ioctl_linux.uu b/drivers/net/wireless/rtl8192c/os_dep/linux/ioctl_linux.uu index f780da17dc2f..ad7ff64b2bea 100644 --- a/drivers/net/wireless/rtl8192c/os_dep/linux/ioctl_linux.uu +++ b/drivers/net/wireless/rtl8192c/os_dep/linux/ioctl_linux.uu @@ -1,546 +1,547 @@ 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(#`%/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.@%P'C`2"$YP-`H.$0 -M``#J`0`1XPH```H(.P'C`S"4YP,`4^,)``"*`#"@XP@K`>,",(3GH"(#`%/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.X%P'C`2"$YP-`H.$0 +M``#J`0`1XPH```H@.P'C`S"4YP,`4^,)``"*`#"@XR`K`>,",(3GN",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(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.,!,(,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!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.%_/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@$``*#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$"$``*#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^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.#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$$,(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!(`,*#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.*```:`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``#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\$+@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>((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",",(3GI",",(3G&0``Z@$)$^,,```*`""@XPP[`>,#((3G`3"@ -MXZ`G`>,",(3GI",",(3G"@``Z@`PH.,,*P'C -M`C"$YZ`G`>,",(3GI",",(3G"%"-Y;0PUN$` -M`%/C!@``"@4`4^,%,*"3#3"@@PPPC>4,,(/B!#"-Y1T``.H`,*#C##"-Y0$` -M6.,9```:J#,",(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\$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,(`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,#,);G!@!3XP0`4Q,& -M```:I#]Z`!` -MH.,```#J7D#@XP4`H.$)$*#A_O__Z_;__^H4`0``'`$``/!'+>D`D*#A`J"@ -MX0-@H.&VAP0"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_#@-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#((,(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_#,#((;G!B"@XPP[`>,#((;G!0``Z@4@H./\-P'C`R"&YP`@H.,,.P'C`R"& -MYPA0G>4!4$7B#P!5XP7QGY,#((;G!""@XPP[`>,#((;G/0``Z@0@H..D-P'C`R"& -MYP8@H.,,.P'C`R"&YS8``.H%(*#CI#,#(,;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+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(,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`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.,4&D*#A?V`"X@<`5N$&<*`A"!!DX*8PH.$!`!+C"2"@`0L@H!$`((WE -M!`"@X0H@H.'^___K?2#5Y0%0A>(``%+C`$"$$.[__QH4! -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+^ -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.-&-(`$`#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 -MN(`,*`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#,(`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_#^,M?A#0!3XP0@@@+\-P$#`R"& -M!S@``.H$`*#A,!>?Y?[__^L``%#C'@``&@(@H./\-P'C`R"&YR0`U^4#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#B``*&X+XBU^$$`(#B,!"'XA``4N,0(*`C_O__ZP(``.H`(*#C -M_#_/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#```*%P"@X_[__^L`H%#B`P``&@D`H.$<$*#C_O__ZQ8``.H4 -M`(GB_O__ZQ4PH..P,,GA!*")Y140,(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^,$((("_#,#((;G)"#7Y08[H.,#((;G`2"@X[X_@^(#(,;GOS]#X@,@EN=8,$/B`R"& -MYP8`H.$P$(?B&>$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.,#(-3GBC4!X],`E.$K-@/C`P#$YRHV`^,#$,3G+#8# +MXP,@Q.@>_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->```*%$"=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.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><`,`#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,+```*`0!5X[$``!H&`*#A!Q"@X7,@[^;^___KK```Z@8` +MH.$'$*#A;``#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-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$@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\$("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.#C7^___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>]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><",(/@<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.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",",(3GO",",(3G&0`` +MZ@$)$^,,```*`""@XR0[`>,#((3G`3"@X[@G`>,",(3GO",",(3G"@``Z@`PH.,D*P'C`C"$Y[@G`>,",(3GO",",(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"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,#,);G!@!3XP0`4Q,&```:O#]Z`!`H.,```#J7D#@XP4`H.$)$*#A_O__ +MZ_;__^H4`0``'`$``/!'+>D`D*#A`J"@X0-@H.&VAP0"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#((,(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,#((;G!""@ +MXR0[`>,#((;G/0``Z@0@H..\-P'C`R"&YP8@H.,D.P'C`R"&YS8``.H%(*#C +MO#,#(,;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+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(,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`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.,4&D*#A?V`"X@<`5N$&<*`A +M"!!DX*8PH.$!`!+C"2"@`0L@H!$`((WE!`"@X0H@H.'^___K?2#5Y0%0A>(` +M`%+C`$"$$.[__QH4!`%+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+^___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-(`$`#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%($+BD4T$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$,#((;GOC+7 +MX0T`4^,$((("%#@!`P,@A@<[``#J!`"@X4P7G^7^___K``!0XR$``!H"(*#C +M%#@!XP,@AN,#((;G)"#7Y1@X`>,# +M((;G`2"@X[X_@^(#(,;GOS]#X@,@EN=8,$/B`R"&YP8`H.$P$(?B,#,);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$`*#A47,*#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_/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#_````"4P -M,G@)`"5S("4P,E@`)7,)`"5S"@!R;6%P`````"5S(#!X)3`R6````"5S(`!R -M96%LF5=(#T@)60`)7,@.B!#;VUM86YD(&YO -M="!F;W5N9`H`=VUA<`````!W"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%S2`A/2!!4E!(4D1?151(15(N"@```"5C``!!3D12 -M3TE$7U=)1DE?0TU$7U-405)4+BXN+BXN+BXN+@H```!W86ET:6YG(&9O2XN+@H`4U1!4E0```!/2P``04Y$4D]) -M1%]7249)7T--1%]35$]0+BXN+BXN+BXN+@H`````4U1/4`````!7249)(')S -M#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"@``6UT86(`+G-T`(```````````$`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"```````````!`!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,`%]G971?;6]D90!R='=?=WA?9V5T7W-E;G,`%]G971?9G)A9P!R='=? -M=WA?9V5T7W)E=')Y`')T=U]W>%]G971?<&]W97(`%]P%]G971?'1?:&1L`')T=U]S971?<&ED`')T=U]P,G!?%]R96%D7W)F`"Y,0S``%]W%]S971?<&UK:60`%]G971?97-S -M:60`7!T:6]N`"Y,0S(X`')T=U]W>%]S971?96YC7V5X=``N3$,R.0`N3$,S,``N -M3$,S,0!R='=?=WA?%]S971?9V5N7VEE`')T=U]W>%]G971?%]G971?%]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?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@`5]D;VUA:6X`=6E?<&ED -M`&UA8U]R96=?9'5M<`!B8E]R96=?9'5M<`!R9E]R96=?9'5M<`!S<')I;G1F -M`%]R='=?;65M5]F5\R -M8VAA0!R='=?8VAA;F=E7VEF;F%M -M90!?0!R='=?=F%L:61A -M=&5?&ET`'=A:V5?;&]C:U]D97-T!```"P3`0"($```'!0!`-`0```!$``"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$````<,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^``!\)```'`"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```+```!2```9V5T7W-E;G-I +M=&EV:71Y`.B+```!2```=W!S7W!R;V)?J+```!2```8VAA;FYE;%]P;&%N`````.N+```"2```9&)G +M`````````````````.R+```#2``````+````')E86QM87``)7,@"@`````E"4P,E@````E#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`0`N +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````````````*`.```````````!`.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`````````````!````!```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`%]G971? +M%]S971?9G)A9P!R='=?=WA?9V5T7V9R86<`0!R='=?=WA?9V5T7W!O=V5R`')T=U]W>%]W%]S971?;71K7W=P%]S971?;71K7W=P%]G971? +M96YC`')T=U]W>%]G971?;FEC:P`N3$,R-P!R='=?=WA?9V5T7V5S%]G971?=V%P`')T=U]W>%]S971?96YC`'=P85]S971?96YC%]S971?97-S:60`%]G971?%]G971?9G)E<0!T%]S971?=V%P`')T=U]W>%]S971?F5R;P!S=')S97``F4`969U5]T;U]U0!R +M='=?0!R=&PX,3@X7W!O=V5R +M7W-A=F5?:6YI=`!W86ME7VQO8VM?:6YI=`!R='=?`@``"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`,@+````T``!P/`0"T +M#0``'`L!`-P-```<$`$`\`T``"M1``#T#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)```'```#,,@`` -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`````!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#$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-```%(```("``!\ -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```'`%H``!PQ -M`0"46@``'````"\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`````#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`````"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````"\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 diff --git a/drivers/net/wireless/rtl8192c/os_dep/linux/usb_intf.c b/drivers/net/wireless/rtl8192c/os_dep/linux/usb_intf.c old mode 100755 new mode 100644 diff --git a/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_power.c b/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_power.c index a0789f01d582..4e418bc80b74 100644 --- a/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_power.c +++ b/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_power.c @@ -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 diff --git a/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_version.h b/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_version.h index aa49464d0535..e60ef105a17f 100755 --- a/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_version.h +++ b/drivers/net/wireless/rtl8192c/os_dep/linux/wifi_version.h @@ -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 */ diff --git a/drivers/power/wm831x_charger_display.c b/drivers/power/wm831x_charger_display.c index 36fc26d04f7f..c08fa6bbcc18 100755 --- a/drivers/power/wm831x_charger_display.c +++ b/drivers/power/wm831x_charger_display.c @@ -38,7 +38,6 @@ #include #include - #define READ_ON_PIN_CNT 20/*11*/ #define BACKLIGHT_CNT 2 #define OPEN_CNT 18 @@ -113,10 +112,21 @@ static int charger_logo_display(struct linux_logo *logo) return 0; } +extern int charger_suspend(void);//xsf + static int charger_backlight_ctrl(int open) { DBG("%s:open=%d\n",__FUNCTION__,open); + int ret; + +#ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND + charger_suspend(); + return 0; +#else return rk29_backlight_ctrl(open); +#endif + + } static int wm831x_read_on_pin_status(struct wm831x_chg *wm831x_chg) @@ -279,7 +289,7 @@ static int wm831x_check_on_pin(struct wm831x_chg *wm831x_chg) if(wm831x_chg->cnt_on >= 1) { wm831x_chg->flag_bl = !wm831x_chg->flag_bl; - charger_backlight_ctrl(wm831x_chg->flag_bl); + charger_backlight_ctrl(wm831x_chg->flag_bl); wm831x_chg->cnt_on = 0; if(wm831x_chg->flag_bl) { @@ -297,6 +307,7 @@ static int rk29_charger_display(struct wm831x_chg *wm831x_chg) int status; struct linux_logo* chargerlogo[8]; int ret,i; + int count = 0; wm831x_chg->flag_chg = wm831x_read_chg_status(wm831x_chg); if(!wm831x_chg->flag_chg) @@ -320,9 +331,12 @@ static int rk29_charger_display(struct wm831x_chg *wm831x_chg) wm831x_chg->flag_chg = wm831x_read_chg_status(wm831x_chg); if(!wm831x_chg->flag_chg) kernel_power_off(); + #ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND + ret = charger_logo_display(chargerlogo[i]); + #else if(wm831x_chg->flag_bl != 0) ret = charger_logo_display(chargerlogo[i]); - + #endif DBG("%s:i=%d\n",__FUNCTION__,i); msleep(200); @@ -335,8 +349,13 @@ static int rk29_charger_display(struct wm831x_chg *wm831x_chg) } else if(status == BAT_DISCHARGING) { + + #ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND + charger_logo_display(chargerlogo[7]); + #else if(wm831x_chg->flag_bl != 0) charger_logo_display(chargerlogo[7]); + #endif msleep(200); wm831x_check_on_pin(wm831x_chg); msleep(200); @@ -352,6 +371,10 @@ static int rk29_charger_display(struct wm831x_chg *wm831x_chg) wm831x_chg->cnt_disp = 0; wm831x_chg->flag_bl = 0; charger_backlight_ctrl(wm831x_chg->flag_bl); + #ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND + wm831x_chg->flag_suspend = 0; + #endif + } wm831x_chg->cnt_disp = 0; } @@ -374,11 +397,26 @@ static int rk29_charger_display(struct wm831x_chg *wm831x_chg) return 0; } +int charge_status; +static irqreturn_t wm831x_charge_irq(int irq, void *data) +{ + + printk("wm831x_charge_irqxxaddxsf\n"); + return IRQ_HANDLED; + + +} +extern struct wm831x_on *g_wm831x_on; + irqreturn_t wm831x_on_irq(int irq, void *data); static int __devinit wm831x_chg_probe(struct platform_device *pdev) { struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);; struct wm831x_chg *wm831x_chg; + +// struct wm831x_on *wm831x_on = container_of(wm831x,struct wm831x_on,*(wm831x)); + + int ret; wm831x_chg = kzalloc(sizeof(struct wm831x_chg), GFP_KERNEL); @@ -386,6 +424,7 @@ static int __devinit wm831x_chg_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Can't allocate data\n"); return -ENOMEM; } + charge_status = 1; printk("%s:start\n",__FUNCTION__); wm831x_chg->wm831x = wm831x; wm831x_chg->flag_chg = 0; @@ -393,16 +432,34 @@ static int __devinit wm831x_chg_probe(struct platform_device *pdev) wm831x_chg->flag_bl = 1; wm831x_chg->cnt_on = 0; wm831x_chg->flag_suspend = 0; - platform_set_drvdata(pdev, wm831x_chg); + +#ifdef CONFIG_RK29_CHARGE_EARLYSUSPEND + wm831x_chg->flag_chg = wm831x_read_chg_status(wm831x_chg); + if(wm831x_chg->flag_chg != 0) + { + free_irq(wm831x_chg->wm831x->irq_base + WM831X_IRQ_ON,g_wm831x_on); + request_threaded_irq(wm831x_chg->wm831x->irq_base + WM831X_IRQ_ON, + NULL, wm831x_charge_irq,IRQF_TRIGGER_RISING, "wm831x_charge", + wm831x_chg); + + ret = rk29_charger_display(wm831x_chg); + + + free_irq(wm831x_chg->wm831x->irq_base + WM831X_IRQ_ON,wm831x_chg); + request_threaded_irq(wm831x_chg->wm831x->irq_base + WM831X_IRQ_ON, + NULL, wm831x_on_irq,IRQF_TRIGGER_RISING, "wm831x_on", g_wm831x_on); + } +#else disable_irq_nosync(wm831x_chg->wm831x->irq_base + WM831X_IRQ_ON); ret = rk29_charger_display(wm831x_chg); enable_irq(wm831x_chg->wm831x->irq_base + WM831X_IRQ_ON); +#endif wm831x_chg->flag_chg = 0; wm831x_chg->flag_bl = 1; wm831x_chg->cnt_on = 0; wm831x_chg->flag_suspend = 0; - + charge_status = 0; printk("%s:exit\n",__FUNCTION__); return 0; diff --git a/drivers/power/wm831x_power.c b/drivers/power/wm831x_power.c index 1fd5e93204d2..51f9b54baa40 100755 --- a/drivers/power/wm831x_power.c +++ b/drivers/power/wm831x_power.c @@ -168,7 +168,7 @@ static int wm831x_power_read_voltage(struct wm831x *wm831x, int ret; ret = wm831x_auxadc_read_uv(wm831x, src); if (ret >= 0) - val->intval = ret / 1000; + val->intval = ret; return ret ; } @@ -184,7 +184,7 @@ int wm831x_read_batt_voltage(void) } ret = wm831x_auxadc_read_uv(g_wm831x_power->wm831x, WM831X_AUX_BATT); - return ret / 1000; + return ret; } //EXPORT_SYMBOL_GPL(wm831x_get_batt_voltage); @@ -475,6 +475,7 @@ static int wm831x_bat_check_status(struct wm831x *wm831x, int *status) if (ret < 0) return ret; + switch (ret & WM831X_CHG_STATE_MASK) { case WM831X_CHG_STATE_OFF: *status = POWER_SUPPLY_STATUS_NOT_CHARGING; @@ -605,7 +606,7 @@ static int wm831x_bat_get_prop(struct power_supply *psy, { struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev->parent); struct wm831x *wm831x = wm831x_power->wm831x; - int ret = 0; + int ret = 0; switch (psp) { case POWER_SUPPLY_PROP_STATUS: @@ -619,7 +620,7 @@ static int wm831x_bat_get_prop(struct power_supply *psy, break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: //ret = wm831x_power_read_voltage(wm831x, WM831X_AUX_BATT, val); - val->intval = wm831x_power->batt_info.voltage*1000;//uV + val->intval = wm831x_power->batt_info.voltage;//uV break; case POWER_SUPPLY_PROP_HEALTH: //ret = wm831x_bat_check_health(wm831x, &val->intval); @@ -716,6 +717,7 @@ static irqreturn_t wm831x_pwr_src_irq(int irq, void *data) power_supply_changed(&wm831x_power->usb); power_supply_changed(&wm831x_power->wall); + return IRQ_HANDLED; } @@ -986,7 +988,7 @@ static void wm831x_batt_work(struct work_struct *work) } power->batt_info.voltage = val.intval; - wm831x_batt_vol_level(power, val.intval, &level); + wm831x_batt_vol_level(power, val.intval / 1000, &level); //mod_timer(&power->timer, jiffies + msecs_to_jiffies(power->interval)); if (online != power->batt_info.online || status != power->batt_info.status @@ -1093,7 +1095,7 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev) power->interval = TIMER_MS_COUNTS; power->batt_info.level = 100; - power->batt_info.voltage = 4200; + power->batt_info.voltage = 4200000; power->batt_info.online = 1; power->batt_info.status = POWER_SUPPLY_STATUS_DISCHARGING; power->batt_info.health = POWER_SUPPLY_HEALTH_GOOD; @@ -1236,7 +1238,7 @@ static ssize_t power_prop_show(struct device *dev, ret = wm831x_power_read_voltage(g_wm831x_power->wm831x, WM831X_AUX_BATT, &val); if (ret < 0) return ret; - wm831x_batt_vol_level(g_wm831x_power, val.intval, &level); + wm831x_batt_vol_level(g_wm831x_power, val.intval / 1000, &level); //printk("batt_vol = %d batt_level = %d\n", val.intval, level); // sprintf(buf, "power_status=%#x\n" diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 5ae9605aed1a..5607a160fde5 100755 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c @@ -32,6 +32,13 @@ #include #include +//#include "../../arch/arm/mach-rk29/include/mach/gpio.h" + +//#include + + + + #define WM831X_BUCKV_MAX_SELECTOR 0x68 #define WM831X_BUCKP_MAX_SELECTOR 0x66 @@ -126,7 +133,6 @@ static unsigned int wm831x_dcdc_get_mode(struct regulator_dev *rdev) return REGULATOR_MODE_IDLE; default: BUG(); - return -EINVAL; } } @@ -307,7 +313,9 @@ static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state) return 0; } +//wm831x_buckv_get_voltage +int wm831x_reg_read(struct wm831x *wm831x, unsigned short reg); static int wm831x_buckv_read_voltage(struct regulator_dev *rdev) { int vol_read; @@ -323,10 +331,12 @@ static int wm831x_buckv_read_voltage(struct regulator_dev *rdev) vol_read = (ret-8)*12500 + 600000; return vol_read; -} + + +} static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV, unsigned *selector) + int min_uV, int max_uV) { struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x *wm831x = dcdc->wm831x; @@ -338,8 +348,6 @@ static int wm831x_buckv_set_voltage(struct regulator_dev *rdev, if (vsel < 0) return vsel; - *selector = vsel; - /* If this value is already set then do a GPIO update if we can */ if (dcdc->dvs_gpio && dcdc->on_vsel == vsel) return wm831x_buckv_set_dvs(rdev, 0); @@ -401,14 +409,14 @@ static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev, return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel); } -static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev) +static int wm831x_buckv_get_voltage(struct regulator_dev *rdev) { struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); if (dcdc->dvs_gpio && dcdc->dvs_gpio_state) - return dcdc->dvs_vsel; + return wm831x_buckv_list_voltage(rdev, dcdc->dvs_vsel); else - return dcdc->on_vsel; + return wm831x_buckv_list_voltage(rdev, dcdc->on_vsel); } /* Current limit options */ @@ -427,9 +435,11 @@ static int wm831x_buckv_set_voltage_step(struct regulator_dev * rdev, int min_uV struct wm831x *wm831x = dcdc->wm831x; struct wm831x_pdata *pdata = wm831x->dev->platform_data; + //if(strcmp(rdev->constraints->name,"DCDC2") != 0) if(strcmp(pdata->dcdc[1]->consumer_supplies[1].supply,"vcore") != 0) { + ret = wm831x_buckv_set_voltage(rdev,min_uV,max_uV); } else @@ -454,9 +464,12 @@ static int wm831x_buckv_set_voltage_step(struct regulator_dev * rdev, int min_uV if(new_min_uV > min_uV) //0< old_vol - min_uV < 100000 ||0< new_min_uV - min_uV < 1000000 { + ret = wm831x_buckv_set_voltage(rdev,min_uV,max_uV); usleep_range(1000,1000); + } + } else //rise voltage { @@ -475,10 +488,12 @@ static int wm831x_buckv_set_voltage_step(struct regulator_dev * rdev, int min_uV ret = wm831x_buckv_set_voltage(rdev,min_uV,max_uV); usleep_range(1000,1000); } - } - } + } + + } return ret; + } static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev, @@ -513,19 +528,20 @@ static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev) return wm831x_dcdc_ilim[val & WM831X_DC1_HC_THR_MASK]; } -static int wm831x_dcdc_set_suspend_enable(struct regulator_dev *rdev) +int wm831x_dcdc_set_suspend_enable(struct regulator_dev *rdev) { + return 0; } - -static int wm831x_dcdc_set_suspend_disable(struct regulator_dev *rdev) +int wm831x_dcdc_set_suspend_disable(struct regulator_dev *rdev) { + return 0; } static struct regulator_ops wm831x_buckv_ops = { .set_voltage = wm831x_buckv_set_voltage_step, - .get_voltage_sel = wm831x_buckv_get_voltage_sel, + .get_voltage = wm831x_buckv_get_voltage, .list_voltage = wm831x_buckv_list_voltage, .set_suspend_voltage = wm831x_buckv_set_suspend_voltage, .set_current_limit = wm831x_buckv_set_current_limit, @@ -665,8 +681,9 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "UV"); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, - IRQF_TRIGGER_RISING, dcdc->name, dcdc); + ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_uv_irq, + IRQF_TRIGGER_RISING, dcdc->name, + dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -674,8 +691,9 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "HC"); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq, - IRQF_TRIGGER_RISING, dcdc->name, dcdc); + ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_oc_irq, + IRQF_TRIGGER_RISING, dcdc->name, + dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", irq, ret); @@ -687,7 +705,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) return 0; err_uv: - free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); err_regulator: regulator_unregister(dcdc->regulator); err: @@ -700,11 +718,12 @@ err: static __devexit int wm831x_buckv_remove(struct platform_device *pdev) { struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); + struct wm831x *wm831x = dcdc->wm831x; platform_set_drvdata(pdev, NULL); - free_irq(platform_get_irq_byname(pdev, "HC"), dcdc); - free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "HC"), dcdc); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); regulator_unregister(dcdc->regulator); if (dcdc->dvs_gpio) gpio_free(dcdc->dvs_gpio); @@ -736,7 +755,7 @@ static int wm831x_buckp_list_voltage(struct regulator_dev *rdev, } static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, - int min_uV, int max_uV, int *selector) + int min_uV, int max_uV) { struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x *wm831x = dcdc->wm831x; @@ -750,20 +769,16 @@ static int wm831x_buckp_set_voltage_int(struct regulator_dev *rdev, int reg, if (wm831x_buckp_list_voltage(rdev, vsel) > max_uV) return -EINVAL; - *selector = vsel; - return wm831x_set_bits(wm831x, reg, WM831X_DC3_ON_VSEL_MASK, vsel); } static int wm831x_buckp_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV, - unsigned *selector) + int min_uV, int max_uV) { struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG; - return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV, - selector); + return wm831x_buckp_set_voltage_int(rdev, reg, min_uV, max_uV); } static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, @@ -771,12 +786,11 @@ static int wm831x_buckp_set_suspend_voltage(struct regulator_dev *rdev, { struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL; - unsigned selector; - return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV, &selector); + return wm831x_buckp_set_voltage_int(rdev, reg, uV, uV); } -static int wm831x_buckp_get_voltage_sel(struct regulator_dev *rdev) +static int wm831x_buckp_get_voltage(struct regulator_dev *rdev) { struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev); struct wm831x *wm831x = dcdc->wm831x; @@ -787,12 +801,12 @@ static int wm831x_buckp_get_voltage_sel(struct regulator_dev *rdev) if (val < 0) return val; - return val & WM831X_DC3_ON_VSEL_MASK; + return wm831x_buckp_list_voltage(rdev, val & WM831X_DC3_ON_VSEL_MASK); } static struct regulator_ops wm831x_buckp_ops = { .set_voltage = wm831x_buckp_set_voltage, - .get_voltage_sel = wm831x_buckp_get_voltage_sel, + .get_voltage = wm831x_buckp_get_voltage, .list_voltage = wm831x_buckp_list_voltage, .set_suspend_voltage = wm831x_buckp_set_suspend_voltage, @@ -855,8 +869,9 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "UV"); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, - IRQF_TRIGGER_RISING, dcdc->name, dcdc); + ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_uv_irq, + IRQF_TRIGGER_RISING, dcdc->name, + dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -877,10 +892,11 @@ err: static __devexit int wm831x_buckp_remove(struct platform_device *pdev) { struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); + struct wm831x *wm831x = dcdc->wm831x; platform_set_drvdata(pdev, NULL); - free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); regulator_unregister(dcdc->regulator); kfree(dcdc); @@ -982,9 +998,9 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "UV"); - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, - IRQF_TRIGGER_RISING, dcdc->name, - dcdc); + ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_uv_irq, + IRQF_TRIGGER_RISING, dcdc->name, + dcdc); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -1005,10 +1021,11 @@ err: static __devexit int wm831x_boostp_remove(struct platform_device *pdev) { struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); + struct wm831x *wm831x = dcdc->wm831x; platform_set_drvdata(pdev, NULL); - free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); regulator_unregister(dcdc->regulator); kfree(dcdc); diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 99f214dd2286..e754528100f8 100755 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c @@ -200,15 +200,10 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev) } irq = platform_get_irq(pdev, 0); -<<<<<<< HEAD - ret = request_threaded_irq(irq, NULL, wm831x_isink_irq, - IRQF_TRIGGER_RISING, isink->name, isink); -======= printk("%s:line=%d,irq=%d\n",__FUNCTION__,__LINE__,irq); ret = wm831x_request_irq(wm831x, irq, wm831x_isink_irq, IRQF_TRIGGER_RISING, isink->name, isink); ->>>>>>> parent of 15f7fab... temp revert rk change if (ret != 0) { dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", irq, ret); @@ -229,10 +224,11 @@ err: static __devexit int wm831x_isink_remove(struct platform_device *pdev) { struct wm831x_isink *isink = platform_get_drvdata(pdev); + struct wm831x *wm831x = isink->wm831x; platform_set_drvdata(pdev, NULL); - free_irq(platform_get_irq(pdev, 0), isink); + wm831x_free_irq(wm831x, platform_get_irq(pdev, 0), isink); regulator_unregister(isink->regulator); kfree(isink); diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 214ac7200e43..885844a33524 100755 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c @@ -115,8 +115,7 @@ static int wm831x_gp_ldo_list_voltage(struct regulator_dev *rdev, } static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, - int min_uV, int max_uV, - unsigned *selector) + int min_uV, int max_uV) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x *wm831x = ldo->wm831x; @@ -136,20 +135,16 @@ static int wm831x_gp_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, if (ret < min_uV || ret > max_uV) return -EINVAL; - *selector = vsel; - return wm831x_set_bits(wm831x, reg, WM831X_LDO1_ON_VSEL_MASK, vsel); } static int wm831x_gp_ldo_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV, - unsigned *selector) + int min_uV, int max_uV) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); int reg = ldo->base + WM831X_LDO_ON_CONTROL; - - return wm831x_gp_ldo_set_voltage_int(rdev, reg, min_uV, max_uV, - selector); + //printk("%s base=%x,%d,%d\n", __FUNCTION__,ldo->base,min_uV,max_uV); + return wm831x_gp_ldo_set_voltage_int(rdev, reg, min_uV, max_uV); } static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, @@ -157,12 +152,11 @@ static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; - unsigned int selector; - return wm831x_gp_ldo_set_voltage_int(rdev, reg, uV, uV, &selector); + return wm831x_gp_ldo_set_voltage_int(rdev, reg, uV, uV); } -static int wm831x_gp_ldo_get_voltage_sel(struct regulator_dev *rdev) +static int wm831x_gp_ldo_get_voltage(struct regulator_dev *rdev) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x *wm831x = ldo->wm831x; @@ -175,7 +169,7 @@ static int wm831x_gp_ldo_get_voltage_sel(struct regulator_dev *rdev) //printk("%s base=%x,ret=%x\n", __FUNCTION__,ldo->base,ret); ret &= WM831X_LDO1_ON_VSEL_MASK; - return ret; + return wm831x_gp_ldo_list_voltage(rdev, ret); } static unsigned int wm831x_gp_ldo_get_mode(struct regulator_dev *rdev) @@ -305,7 +299,7 @@ int wm831x_ldo_set_suspend_disable(struct regulator_dev *rdev) static struct regulator_ops wm831x_gp_ldo_ops = { .list_voltage = wm831x_gp_ldo_list_voltage, - .get_voltage_sel = wm831x_gp_ldo_get_voltage_sel, + .get_voltage = wm831x_gp_ldo_get_voltage, .set_voltage = wm831x_gp_ldo_set_voltage, .set_suspend_voltage = wm831x_gp_ldo_set_suspend_voltage, .get_mode = wm831x_gp_ldo_get_mode, @@ -368,9 +362,9 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "UV"); - ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, - IRQF_TRIGGER_RISING, ldo->name, - ldo); + ret = wm831x_request_irq(wm831x, irq, wm831x_ldo_uv_irq, + IRQF_TRIGGER_RISING, ldo->name, + ldo); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -391,10 +385,11 @@ err: static __devexit int wm831x_gp_ldo_remove(struct platform_device *pdev) { struct wm831x_ldo *ldo = platform_get_drvdata(pdev); + struct wm831x *wm831x = ldo->wm831x; platform_set_drvdata(pdev, NULL); - free_irq(platform_get_irq_byname(pdev, "UV"), ldo); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), ldo); regulator_unregister(ldo->regulator); kfree(ldo); @@ -432,8 +427,7 @@ static int wm831x_aldo_list_voltage(struct regulator_dev *rdev, } static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, - int min_uV, int max_uV, - unsigned *selector) + int min_uV, int max_uV) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x *wm831x = ldo->wm831x; @@ -453,20 +447,16 @@ static int wm831x_aldo_set_voltage_int(struct regulator_dev *rdev, int reg, if (ret < min_uV || ret > max_uV) return -EINVAL; - *selector = vsel; - return wm831x_set_bits(wm831x, reg, WM831X_LDO7_ON_VSEL_MASK, vsel); } static int wm831x_aldo_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV, unsigned *selector) + int min_uV, int max_uV) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); int reg = ldo->base + WM831X_LDO_ON_CONTROL; - printk("%s base=%x,min_uV=%d,%d\n", __FUNCTION__,ldo->base,min_uV,max_uV); - return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV, - selector); + return wm831x_aldo_set_voltage_int(rdev, reg, min_uV, max_uV); } static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, @@ -474,12 +464,11 @@ static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); int reg = ldo->base + WM831X_LDO_SLEEP_CONTROL; - unsigned int selector; - return wm831x_aldo_set_voltage_int(rdev, reg, uV, uV, &selector); + return wm831x_aldo_set_voltage_int(rdev, reg, uV, uV); } -static int wm831x_aldo_get_voltage_sel(struct regulator_dev *rdev) +static int wm831x_aldo_get_voltage(struct regulator_dev *rdev) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x *wm831x = ldo->wm831x; @@ -492,7 +481,7 @@ static int wm831x_aldo_get_voltage_sel(struct regulator_dev *rdev) printk("%s base=%x,ret=%x\n", __FUNCTION__,ldo->base,ret); ret &= WM831X_LDO7_ON_VSEL_MASK; - return ret; + return wm831x_aldo_list_voltage(rdev, ret); } static unsigned int wm831x_aldo_get_mode(struct regulator_dev *rdev) @@ -573,7 +562,7 @@ static int wm831x_aldo_get_status(struct regulator_dev *rdev) static struct regulator_ops wm831x_aldo_ops = { .list_voltage = wm831x_aldo_list_voltage, - .get_voltage_sel = wm831x_aldo_get_voltage_sel, + .get_voltage = wm831x_aldo_get_voltage, .set_voltage = wm831x_aldo_set_voltage, .set_suspend_voltage = wm831x_aldo_set_suspend_voltage, .get_mode = wm831x_aldo_get_mode, @@ -635,8 +624,9 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev) } irq = platform_get_irq_byname(pdev, "UV"); - ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, - IRQF_TRIGGER_RISING, ldo->name, ldo); + ret = wm831x_request_irq(wm831x, irq, wm831x_ldo_uv_irq, + IRQF_TRIGGER_RISING, ldo->name, + ldo); if (ret != 0) { dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", irq, ret); @@ -657,8 +647,9 @@ err: static __devexit int wm831x_aldo_remove(struct platform_device *pdev) { struct wm831x_ldo *ldo = platform_get_drvdata(pdev); + struct wm831x *wm831x = ldo->wm831x; - free_irq(platform_get_irq_byname(pdev, "UV"), ldo); + wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), ldo); regulator_unregister(ldo->regulator); kfree(ldo); @@ -691,8 +682,7 @@ static int wm831x_alive_ldo_list_voltage(struct regulator_dev *rdev, static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, int reg, - int min_uV, int max_uV, - unsigned *selector) + int min_uV, int max_uV) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x *wm831x = ldo->wm831x; @@ -706,20 +696,16 @@ static int wm831x_alive_ldo_set_voltage_int(struct regulator_dev *rdev, if (ret < min_uV || ret > max_uV) return -EINVAL; - *selector = vsel; - return wm831x_set_bits(wm831x, reg, WM831X_LDO11_ON_VSEL_MASK, vsel); } static int wm831x_alive_ldo_set_voltage(struct regulator_dev *rdev, - int min_uV, int max_uV, - unsigned *selector) + int min_uV, int max_uV) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); int reg = ldo->base + WM831X_ALIVE_LDO_ON_CONTROL; - return wm831x_alive_ldo_set_voltage_int(rdev, reg, min_uV, max_uV, - selector); + return wm831x_alive_ldo_set_voltage_int(rdev, reg, min_uV, max_uV); } static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, @@ -727,12 +713,11 @@ static int wm831x_alive_ldo_set_suspend_voltage(struct regulator_dev *rdev, { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); int reg = ldo->base + WM831X_ALIVE_LDO_SLEEP_CONTROL; - unsigned selector; - return wm831x_alive_ldo_set_voltage_int(rdev, reg, uV, uV, &selector); + return wm831x_alive_ldo_set_voltage_int(rdev, reg, uV, uV); } -static int wm831x_alive_ldo_get_voltage_sel(struct regulator_dev *rdev) +static int wm831x_alive_ldo_get_voltage(struct regulator_dev *rdev) { struct wm831x_ldo *ldo = rdev_get_drvdata(rdev); struct wm831x *wm831x = ldo->wm831x; @@ -745,7 +730,7 @@ static int wm831x_alive_ldo_get_voltage_sel(struct regulator_dev *rdev) ret &= WM831X_LDO11_ON_VSEL_MASK; - return ret; + return wm831x_alive_ldo_list_voltage(rdev, ret); } static int wm831x_alive_ldo_get_status(struct regulator_dev *rdev) @@ -767,7 +752,7 @@ static int wm831x_alive_ldo_get_status(struct regulator_dev *rdev) static struct regulator_ops wm831x_alive_ldo_ops = { .list_voltage = wm831x_alive_ldo_list_voltage, - .get_voltage_sel = wm831x_alive_ldo_get_voltage_sel, + .get_voltage = wm831x_alive_ldo_get_voltage, .set_voltage = wm831x_alive_ldo_set_voltage, .set_suspend_voltage = wm831x_alive_ldo_set_suspend_voltage, .get_status = wm831x_alive_ldo_get_status, @@ -925,8 +910,7 @@ static int __init wm831x_ldo_init(void) if (ret != 0) pr_err("Failed to register WM831x alive LDO driver: %d\n", ret); - - return 0; + return 0; } subsys_initcall(wm831x_ldo_init); diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h old mode 100755 new mode 100644 index fe019ca7e43c..d86bc0c857da --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_driver.h @@ -149,6 +149,7 @@ typedef struct _gcsHAL_INTERFACE { /* Physical memory address of internal memory. */ OUT gctUINT32 baseAddress; + OUT gctCHAR fwVersion[20]; } GetBaseAddress; diff --git a/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h b/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h old mode 100755 new mode 100644 index 72d8086fcf2c..d98fa36a0b34 --- a/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h +++ b/drivers/staging/rk29/vivante/hal/inc/gc_hal_options.h @@ -261,6 +261,24 @@ #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: ¹Ø±Õ×Ô¶¯µ÷Ƶ @@ -330,5 +348,17 @@ */ #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_ */ diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c old mode 100755 new mode 100644 index ffb10bca4d1f..2363d831fe57 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel.c @@ -19,8 +19,7 @@ *****************************************************************************/ - - +#include #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: diff --git a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c index 0e7be33b3b82..007fe56ad571 100644 --- a/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c +++ b/drivers/staging/rk29/vivante/hal/kernel/gc_hal_kernel_video_memory.c @@ -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) diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c old mode 100755 new mode 100644 index 5a51e129b1cb..3e4518bd9363 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_driver.c @@ -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 diff --git a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c old mode 100755 new mode 100644 index 2581c269ad9d..dee7ef6ac269 --- a/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c +++ b/drivers/staging/rk29/vivante/hal/os/linux/kernel/gc_hal_kernel_os.c @@ -30,7 +30,7 @@ #include #include #include -#ifdef NO_DMA_COHERENT +#if USE_DMA_COHERENT #include #endif /* NO_DMA_COHERENT */ @@ -38,7 +38,6 @@ #include #include #include -#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; ipageNum; 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; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 9b07470c5f9f..576bf90ba773 100755 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -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; } diff --git a/drivers/usb/dwc_otg/dwc_otg_cil.c b/drivers/usb/dwc_otg/dwc_otg_cil.c index 316387d5491f..d0fdfbd44dae 100755 --- a/drivers/usb/dwc_otg/dwc_otg_cil.c +++ b/drivers/usb/dwc_otg/dwc_otg_cil.c @@ -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 */ diff --git a/drivers/usb/dwc_otg/dwc_otg_hcd_intr.c b/drivers/usb/dwc_otg/dwc_otg_hcd_intr.c index 21e341f964fb..8a1665a001d1 100755 --- a/drivers/usb/dwc_otg/dwc_otg_hcd_intr.c +++ b/drivers/usb/dwc_otg/dwc_otg_hcd_intr.c @@ -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; } diff --git a/drivers/video/backlight/rk29_buttonlight.c b/drivers/video/backlight/rk29_buttonlight.c index 342c6eae7c08..0853ff83a236 100755 --- a/drivers/video/backlight/rk29_buttonlight.c +++ b/drivers/video/backlight/rk29_buttonlight.c @@ -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; diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c index cea8e23f0937..ca6d6b9cd2fc 100755 --- a/drivers/video/backlight/wm831x_bl.c +++ b/drivers/video/backlight/wm831x_bl.c @@ -154,7 +154,7 @@ static int wm831x_backlight_get_brightness(struct backlight_device *bl) return data->current_brightness; } -static const struct backlight_ops wm831x_backlight_ops = { +static struct backlight_ops wm831x_backlight_ops = { .options = BL_CORE_SUSPENDRESUME, .update_status = wm831x_backlight_update_status, .get_brightness = wm831x_backlight_get_brightness, @@ -268,10 +268,9 @@ static int wm831x_backlight_probe(struct platform_device *pdev) data->current_brightness = 0; data->isink_reg = isink_reg; - props.type = BACKLIGHT_RAW; - props.max_brightness = BL_SET; + props.max_brightness = max_isel; bl = backlight_device_register("wm831x", &pdev->dev, data, - &wm831x_backlight_ops, &props); + &wm831x_backlight_ops,NULL); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); kfree(data); @@ -279,6 +278,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev) } bl->props.brightness = BL_INIT_VALUE; + bl->props.max_brightness= BL_SET; platform_set_drvdata(pdev, bl); diff --git a/drivers/video/display/screen/Kconfig b/drivers/video/display/screen/Kconfig index 78a8b34365ed..2ec2120c26b9 100755 --- a/drivers/video/display/screen/Kconfig +++ b/drivers/video/display/screen/Kconfig @@ -3,6 +3,8 @@ choice prompt "LCD Panel Select" config LCD_NULL bool "NULL" +config LCD_LG_LP097X02 + bool "RGB LCD_LG_LP097X02 1024X768" config LCD_TD043MGEA1 bool "RGB TD043MGEA1" config LCD_HX8357 @@ -27,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 diff --git a/drivers/video/display/screen/Makefile b/drivers/video/display/screen/Makefile index 79b670c71d4e..0abb52a1214b 100755 --- a/drivers/video/display/screen/Makefile +++ b/drivers/video/display/screen/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_LCD_TD043MGEA1) += lcd_td043mgea1.o obj-$(CONFIG_LCD_HSD070IDW1) += lcd_hsd800x480.o obj-$(CONFIG_LCD_HL070VM4AU) += lcd_hl070vm4.o obj-$(CONFIG_LCD_BYD8688FTGF) += lcd_byd1024x600.o +obj-$(CONFIG_LCD_LG_LP097X02)+= lcd_LG_LP097X02.o obj-$(CONFIG_LCD_TJ048NC01CA) += lcd_tj048nc01ca.o obj-$(CONFIG_LCD_A060SE02) += lcd_a060se02.o @@ -15,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 @@ -30,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_LG_LP097X02.c b/drivers/video/display/screen/lcd_LG_LP097X02.c new file mode 100755 index 000000000000..3a4df9a27267 --- /dev/null +++ b/drivers/video/display/screen/lcd_LG_LP097X02.c @@ -0,0 +1,72 @@ +#include +#include +#include "../../rk29_fb.h" +#include +#include +#include +#include "screen.h" + +/* Base */ +#define OUT_TYPE SCREEN_RGB +#define OUT_FACE OUT_D888_P666 +#define OUT_CLK 100000000 +#define LCDC_ACLK 500000000 +/* Timing */ +#define H_PW 320 +#define H_BP 480 +#define H_VD 1024 +#define H_FP 260 + +#define V_PW 10 +#define V_BP 6 +#define V_VD 768 +#define V_FP 16 + +#define LCD_WIDTH 196// 142 // 202 +#define LCD_HEIGHT 147 //106// 152 +/* Other */ +#define DCLK_POL 0 // +#define SWAP_RB 0 + +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; + screen->right_margin = H_FP; + screen->hsync_len = H_PW; + screen->upper_margin = V_BP; + screen->lower_margin = V_FP; + screen->vsync_len = V_PW; + + /* 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 = NULL; + screen->standby = NULL; +} + + diff --git a/drivers/video/display/screen/lcd_ls035y8dx04a.c b/drivers/video/display/screen/lcd_ls035y8dx04a.c new file mode 100644 index 000000000000..f1757299f798 --- /dev/null +++ b/drivers/video/display/screen/lcd_ls035y8dx04a.c @@ -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 +#include +#include "../../rk29_fb.h" +#include +#include +#include +#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, 4upper_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; +} + diff --git a/drivers/video/hdmi/hdmi-codec.c b/drivers/video/hdmi/hdmi-codec.c index 8a8a09e6f91d..e0360ceb7fd6 100755 --- a/drivers/video/hdmi/hdmi-codec.c +++ b/drivers/video/hdmi/hdmi-codec.c @@ -1,5 +1,5 @@ #include -#ifdef CONFIG_SND_SOC_WM8900 +#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 diff --git a/include/linux/mfd/wm831x/core.h b/include/linux/mfd/wm831x/core.h old mode 100644 new mode 100755 index 4b217b9b8fc7..b702517a76bc --- a/include/linux/mfd/wm831x/core.h +++ b/include/linux/mfd/wm831x/core.h @@ -249,16 +249,6 @@ enum wm831x_parent { WM8325 = 0x8325, }; -enum wm831x_parent { - WM8310 = 0x8310, - WM8311 = 0x8311, - WM8312 = 0x8312, - WM8320 = 0x8320, - WM8321 = 0x8321, - WM8325 = 0x8325, - WM8326 = 0x8326, -}; - struct wm831x { struct mutex io_lock; @@ -361,4 +351,30 @@ int wm831x_device_restart(struct wm831x *wm831x); int wm831x_irq_init(struct wm831x *wm831x, int irq); void wm831x_irq_exit(struct wm831x *wm831x); +static inline int __must_check wm831x_request_irq(struct wm831x *wm831x, + unsigned int irq, + irq_handler_t handler, + unsigned long flags, + const char *name, + void *dev) +{ + return request_threaded_irq(irq, NULL, handler, flags, name, dev); +} + +static inline void wm831x_free_irq(struct wm831x *wm831x, + unsigned int irq, void *dev) +{ + free_irq(irq, dev); +} + +static inline void wm831x_disable_irq(struct wm831x *wm831x, int irq) +{ + disable_irq(irq); +} + +static inline void wm831x_enable_irq(struct wm831x *wm831x, int irq) +{ + enable_irq(irq); +} + #endif diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h index accc729c7970..92cefe8721e1 100755 --- a/include/linux/mfd/wm831x/pdata.h +++ b/include/linux/mfd/wm831x/pdata.h @@ -82,10 +82,7 @@ struct wm831x_touch_pdata { int isel; /** Current for pen down (uA) */ int rpu; /** Pen down sensitivity resistor divider */ int pressure; /** Report pressure (boolean) */ - unsigned int data_irq; /** Touch data ready IRQ */ - int data_irqf; /** IRQ flags for data ready IRQ */ - unsigned int pd_irq; /** Touch pendown detect IRQ */ - int pd_irqf; /** IRQ flags for pen down IRQ */ + int data_irq; /** Touch data ready IRQ */ }; enum wm831x_watchdog_action { @@ -123,23 +120,11 @@ struct wm831x_gpio_keys_pdata { #define WM831X_MAX_LDO 11 #define WM831X_MAX_ISINK 2 -#define WM831X_GPIO_CONFIGURE 0x10000 -#define WM831X_GPIO_NUM 16 - struct wm831x_pdata { - /** Used to distinguish multiple WM831x chips */ - int wm831x_num; - /** Called before subdevices are set up */ int (*pre_init)(struct wm831x *wm831x); /** Called after subdevices are set up */ int (*post_init)(struct wm831x *wm831x); -<<<<<<< HEAD - - /** Put the /IRQ line into CMOS mode */ - bool irq_cmos; - -======= /** Called before subdevices are power down */ int (*last_deinit)(struct wm831x *wm831x); //add by sxj @@ -148,10 +133,8 @@ struct wm831x_pdata { int settinginfolen; int (*pin_type_init)(struct wm831x *wm831x); //above add by sxj ->>>>>>> parent of 15f7fab... temp revert rk change int irq_base; int gpio_base; - int gpio_defaults[WM831X_GPIO_NUM]; struct wm831x_backlight_pdata *backlight; struct wm831x_backup_pdata *backup; struct wm831x_battery_pdata *battery; diff --git a/include/linux/mfd/wm8994/core.h b/include/linux/mfd/wm8994/core.h index 7929fc9d6709..f0b69cdae41c 100644 --- a/include/linux/mfd/wm8994/core.h +++ b/include/linux/mfd/wm8994/core.h @@ -15,7 +15,6 @@ #ifndef __MFD_WM8994_CORE_H__ #define __MFD_WM8994_CORE_H__ -<<<<<<< HEAD #include 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 diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h old mode 100644 new mode 100755 index b47b3cb86c06..97cf4f27d647 --- a/include/linux/mfd/wm8994/pdata.h +++ b/include/linux/mfd/wm8994/pdata.h @@ -29,7 +29,6 @@ struct wm8994_ldo_pdata { #define WM8994_CONFIGURE_GPIO 0x10000 #define WM8994_DRC_REGS 5 -<<<<<<< HEAD #define WM8994_EQ_REGS 20 #define WM8958_MBC_CUTOFF_REGS 20 #define WM8958_MBC_COEFF_REGS 48 @@ -37,9 +36,6 @@ struct wm8994_ldo_pdata { #define WM8958_VSS_HPF_REGS 2 #define WM8958_VSS_REGS 148 #define WM8958_ENH_EQ_REGS 32 -======= -#define WM8994_EQ_REGS 19 ->>>>>>> parent of 15f7fab... temp revert rk change /** * DRC configurations are specified with a label and a set of register @@ -69,7 +65,6 @@ struct wm8994_retune_mobile_cfg { u16 regs[WM8994_EQ_REGS]; }; -<<<<<<< HEAD /** * Multiband compressor configurations are specified with a label and * two sets of values to write. Configurations are expected to be @@ -117,10 +112,6 @@ struct wm8958_enh_eq_cfg { const char *name; u16 regs[WM8958_ENH_EQ_REGS]; }; -======= -#define PCM_BB 1 -#define NO_PCM_BB 0 ->>>>>>> parent of 15f7fab... temp revert rk change struct wm8994_pdata { int gpio_base; @@ -133,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; @@ -173,39 +165,8 @@ struct wm8994_pdata { unsigned int jd_scthr:2; unsigned int jd_thr:2; -<<<<<<< HEAD /* WM8958 microphone bias configuration */ int micbias[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 - ->>>>>>> parent of 15f7fab... temp revert rk change }; #endif diff --git a/include/linux/mtk23d.h b/include/linux/mtk23d.h index 9c5f11a819d5..28facec4e825 100755 --- a/include/linux/mtk23d.h +++ b/include/linux/mtk23d.h @@ -11,6 +11,7 @@ struct modem_dev /* 耳机数æ®ç»“æž„ä½?*/ struct rk2818_23d_data { + struct device *dev; int (*io_init)(void); int (*io_deinit)(void); unsigned int bp_power; diff --git a/include/linux/usb/android_composite.h b/include/linux/usb/android_composite.h new file mode 100644 index 000000000000..50889ba138b9 --- /dev/null +++ b/include/linux/usb/android_composite.h @@ -0,0 +1,98 @@ +/* + * Platform data for Android USB + * + * Copyright (C) 2008 Google, Inc. + * Author: Mike Lockwood + * + * 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_USB_ANDROID_H +#define __LINUX_USB_ANDROID_H + +#include +#include + +struct android_usb_function { + struct list_head list; + char *name; + int (*bind_config)(struct usb_configuration *c); +}; + +struct android_usb_product { + /* Default product ID. */ + __u16 product_id; + + /* List of function names associated with this product. + * This is used to compute the USB product ID dynamically + * based on which functions are enabled. + */ + int num_functions; + char **functions; +}; + +struct android_usb_platform_data { + /* USB device descriptor fields */ + __u16 vendor_id; + + /* Default product ID. */ + __u16 product_id; + + __u16 version; + + char *product_name; + char *manufacturer_name; + char *serial_number; + + /* List of available USB products. + * This is used to compute the USB product ID dynamically + * based on which functions are enabled. + * if num_products is zero or no match can be found, + * we use the default product ID + */ + int num_products; + struct android_usb_product *products; + + /* List of all supported USB functions. + * This list is used to define the order in which + * the functions appear in the configuration's list of USB interfaces. + * This is necessary to avoid depending upon the order in which + * the individual function drivers are initialized. + */ + int num_functions; + char **functions; +}; + +/* Platform data for "usb_mass_storage" driver. */ +struct usb_mass_storage_platform_data { + /* Contains values for the SC_INQUIRY SCSI command. */ + char *vendor; + char *product; + int release; + + /* number of LUNS */ + int nluns; +}; + +/* Platform data for USB ethernet driver. */ +struct usb_ether_platform_data { + u8 ethaddr[ETH_ALEN]; + u32 vendorID; + const char *vendorDescr; +}; + +extern void android_usb_set_connected(int on); + +extern void android_register_function(struct android_usb_function *f); + +extern void android_enable_function(struct usb_function *f, int enable); + + +#endif /* __LINUX_USB_ANDROID_H */ diff --git a/kernel/power/earlysuspend.c b/kernel/power/earlysuspend.c index e073695d44f5..86e14ef1898c 100644 --- a/kernel/power/earlysuspend.c +++ b/kernel/power/earlysuspend.c @@ -20,7 +20,6 @@ #include /* sys_sync */ #include #include -#include #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); } diff --git a/pack-kernel.sh b/pack-kernel.sh index 6bb24bf0bd16..5c78d466a6b9 100755 --- a/pack-kernel.sh +++ b/pack-kernel.sh @@ -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 diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index bd370c66e76a..9dfeb311759f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -74,8 +74,8 @@ 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_alc5631 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 select SND_SOC_WM8904 if I2C @@ -312,10 +312,10 @@ config SND_SOC_WM8804 config SND_SOC_WM8900 tristate -config SND_SOC_alc5621 +config SND_SOC_RT5621 tristate -config SND_SOC_alc5631 +config SND_SOC_RT5631 tristate config SND_SOC_RT5625 diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index d4f5f1599532..b5c69a02e817 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -57,8 +57,8 @@ 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-alc5631-objs := rt5631.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 snd-soc-wm8903-objs := wm8903.o @@ -154,8 +154,8 @@ 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_alc5631) += snd-soc-alc5631.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 obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o diff --git a/sound/soc/codecs/alc5621.c b/sound/soc/codecs/alc5621.c deleted file mode 100644 index ab04ab7dedf9..000000000000 --- a/sound/soc/codecs/alc5621.c +++ /dev/null @@ -1,1932 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "alc5621.h" - -#if REALTEK_HWDEP - -#include -#include - -#endif - -#define AUDIO_NAME "rt5621" -#define RT5621_VERSION "alsa 1.0.21 0.05" - -#ifdef RT5621_DEBUG -#define dbg(format, arg...) \ - printk(KERN_DEBUG AUDIO_NAME ": " format "\n" , ## arg) -#else -#define dbg(format, arg...) do {} while (0) -#endif -#define err(format, arg...) \ - printk(KERN_ERR AUDIO_NAME ": " format "\n" , ## arg) -#define info(format, arg...) \ - printk(KERN_INFO AUDIO_NAME ": " format "\n" , ## arg) -#define warn(format, arg...) \ - printk(KERN_WARNING AUDIO_NAME ": " format "\n" , ## arg) - -static int caps_charge = 500; -module_param(caps_charge, int, 0); -MODULE_PARM_DESC(caps_charge, "RT5621 cap charge time (msecs)"); - -/* codec private data */ -struct rt5621_priv { - unsigned int sysclk; -}; - -static struct snd_soc_device *rt5621_socdev; - -struct rt5621_reg{ - - u8 reg_index; - u16 reg_value; -}; - -static struct rt5621_reg init_data[] = { - {RT5621_AUDIO_INTERFACE, 0x8000}, //set I2S codec to slave mode - {RT5621_STEREO_DAC_VOL, 0x0808}, //default stereo DAC volume to 0db - {RT5621_OUTPUT_MIXER_CTRL, 0x0740}, //default output mixer control - {RT5621_ADC_REC_MIXER, 0x3f3f}, //set record source is Mic1 by default - {RT5621_MIC_CTRL, 0x0500}, //set Mic1,Mic2 boost 20db - {RT5621_SPK_OUT_VOL, 0x8080}, //default speaker volume to 0db - {RT5621_HP_OUT_VOL, 0x8888}, //default HP volume to -12db - {RT5621_ADD_CTRL_REG, 0x5f00}, //Class AB/D speaker ratio is 1VDD - {RT5621_STEREO_AD_DA_CLK_CTRL, 0x066d}, //set Dac filter to 256fs - {RT5621_HID_CTRL_INDEX, 0x46}, //Class D setting - {RT5621_HID_CTRL_DATA, 0xFFFF}, //power on Class D Internal register -}; - -#define RT5621_INIT_REG_NUM ARRAY_SIZE(init_data) - -/* - * rt5621 register cache - * We can't read the RT5621 register space when we - * are using 2 wire for device control, so we cache them instead. - */ -static const u16 rt5621_reg[0x80/2]; - - -/* virtual HP mixers regs */ -#define HPL_MIXER 0x80 -#define HPR_MIXER 0x82 -/*reg84*/ -/*bit0,1:for hp pga power control - *bit2,3:for aux pga power control - */ -#define MISC_FUNC_REG 0x84 -static u16 reg80=0,reg82=0, reg84 = 0; - - -/* - * read rt5621 register cache - */ -static inline unsigned int rt5621_read_reg_cache(struct snd_soc_codec *codec, - unsigned int reg) -{ - u16 *cache = codec->reg_cache; - if (reg < 1 || reg > (ARRAY_SIZE(rt5621_reg) + 1)) - return -1; - return cache[reg/2]; -} - - -/* - * write rt5621 register cache - */ - -static inline void rt5621_write_reg_cache(struct snd_soc_codec *codec, - unsigned int reg, unsigned int value) -{ - u16 *cache = codec->reg_cache; - if (reg < 0 || reg > 0x7e) - return; - cache[reg/2] = value; -} - - - -static int rt5621_write(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value) -{ - u8 data[3]; - - if(reg>0x7E) - { - if(reg==HPL_MIXER) - reg80=value; - else if(reg==HPR_MIXER) - reg82=value; - else if (reg == MISC_FUNC_REG) - reg84 = value; - else - return -EIO; - - return 0; - } - - - printk("rt5621 write reg=%x,value=%x\n",reg,value); - data[0] = reg; - data[1] = (0xFF00 & value) >> 8; - data[2] = 0x00FF & value; - - if (codec->hw_write(codec->control_data, data, 3) == 3) - { - rt5621_write_reg_cache (codec, reg, value); - printk(KERN_INFO "rt5621 write reg=%x,value=%x\n",reg,value); - return 0; - } - else - { - printk(KERN_ERR "rt5621 write faile\n"); - return -EIO; - } -} - - -static unsigned int rt5621_read(struct snd_soc_codec *codec, unsigned int reg) -{ - u8 data[2]={0}; - unsigned int value=0x0; - - if(reg>0x7E) - { - if(reg==HPL_MIXER) - return reg80; - else if(reg==HPR_MIXER) - return reg82; - else if (reg == MISC_FUNC_REG) - return reg84; - else - return -EIO; - - return -EIO; - } - - - data[0] = reg; -//flove031811_S -#if 0 - i2c_master_recv(codec->control_data, data, 2); - - value = (data[0]<<8) | data[1]; - printk("rt5621_read reg%x=%x\n",reg,value); -#elif 1 - - i2c_master_reg8_recv(codec->control_data,reg,data, 2,100 * 1000); - - value = (data[0]<<8) | data[1]; - printk("rt5621_read reg%x=%x\n",reg,value); - return value; - -#else - if(codec->hw_write(codec->control_data, data, 1) ==1) - { - i2c_master_recv(codec->control_data, data, 2); - - value = (data[0]<<8) | data[1]; - printk(KERN_DEBUG "rt5621 read reg%x=%x\n",reg,value); - - return value; - } - else - { - printk(KERN_ERR "rt5621 read faile\n"); - return -EIO; - } -#endif -//flove031811_E -} - -#define rt5621_write_mask(c, reg, value, mask) snd_soc_update_bits(c, reg, mask, value) - - -#define rt5621_reset(c) rt5621_write(c, 0x0, 0) - -static unsigned int rt5621_read_index(struct snd_soc_codec *codec, unsigned int index) -{ - unsigned int value; - - rt5621_write(codec, 0x6a, index); - mdelay(1); - value = rt5621_read(codec, 0x6c); - return value; -} - -static int rt5621_init_reg(struct snd_soc_codec *codec) -{ - int i; - - for (i = 0; i < RT5621_INIT_REG_NUM; i++) - { - rt5621_write(codec, init_data[i].reg_index, init_data[i].reg_value); - } - - return 0; -} - - -#if !USE_DAPM_CONTROL -//***************************************************************************** -// -//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 - - rt5621_write(codec,RT5621_PWR_MANAG_ADD1,~PowerDownState); - rt5621_write(codec,RT5621_PWR_MANAG_ADD2,~PowerDownState); - rt5621_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); - rt5621_write(codec,RT5621_PWR_MANAG_ADD3,0); - rt5621_write(codec,RT5621_PWR_MANAG_ADD1,0); - rt5621_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 - - 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; -} -#endif - - -//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; -} - - - -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), -}; - - - -/* add non dapm controls */ -static int rt5621_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(rt5621_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&rt5621_snd_controls[i],codec, NULL)); - if (err < 0) - return err; - } - return 0; -} - -void hp_depop_mode2(struct snd_soc_codec *codec) -{ - rt5621_write_mask(codec, 0x3e, 0x8000, 0x8000); - rt5621_write_mask(codec, 0x04, 0x8080, 0x8080); - rt5621_write_mask(codec, 0x3a, 0x0100, 0x0100); - rt5621_write_mask(codec, 0x3c, 0x2000, 0x2000); - rt5621_write_mask(codec, 0x3e, 0x0600, 0x0600); - rt5621_write_mask(codec, 0x5e, 0x0200, 0x0200); - schedule_timeout_uninterruptible(msecs_to_jiffies(300)); -} - -void aux_depop_mode2(struct snd_soc_codec *codec) -{ - rt5621_write_mask(codec, 0x3e, 0x8000, 0x8000); - rt5621_write_mask(codec, 0x06, 0x8080, 0x8080); - rt5621_write_mask(codec, 0x3a, 0x0100, 0x0100); - rt5621_write_mask(codec, 0x3c, 0x2000, 0x2000); - rt5621_write_mask(codec, 0x3e, 0x6000, 0x6000); - rt5621_write_mask(codec, 0x5e, 0x0020, 0x0200); - schedule_timeout_uninterruptible(msecs_to_jiffies(300)); - rt5621_write_mask(codec, 0x3a, 0x0002, 0x0002); - rt5621_write_mask(codec, 0x3a, 0x0001, 0x0001); -} -#if USE_DAPM_CONTROL - -/* - * _DAPM_ Controls - */ - -/* We have to create a fake left and right HP mixers because - * the codec only has a single control that is shared by both channels. - * This makes it impossible to determine the audio path using the current - * register map, thus we add a new (virtual) register to help determine the - * audio route within the device. - */ - static int mixer_event (struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - - u16 l, r, lineIn,mic1,mic2, aux, pcm; - - l = rt5621_read(w->codec, HPL_MIXER); - r = rt5621_read(w->codec, HPR_MIXER); - lineIn = rt5621_read(w->codec, RT5621_LINE_IN_VOL); - mic2 = rt5621_read(w->codec, RT5621_MIC_ROUTING_CTRL); - aux = rt5621_read(w->codec,RT5621_AUXIN_VOL); - pcm = rt5621_read(w->codec, RT5621_STEREO_DAC_VOL); - - - if (event & SND_SOC_DAPM_PRE_REG) - return 0; - - if (l & 0x1 || r & 0x1) - rt5621_write(w->codec, RT5621_STEREO_DAC_VOL, pcm & 0x7fff); - else - rt5621_write(w->codec, RT5621_STEREO_DAC_VOL, pcm | 0x8000); - - if (l & 0x2 || r & 0x2) - rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic2 & 0xff7f); - else - rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic2 | 0x0080); - - mic1 = rt5621_read(w->codec, RT5621_MIC_ROUTING_CTRL); - if (l & 0x4 || r & 0x4) - rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic1 & 0x7fff); - else - rt5621_write(w->codec, RT5621_MIC_ROUTING_CTRL, mic1 | 0x8000); - - if (l & 0x8 || r & 0x8) - rt5621_write(w->codec, RT5621_AUXIN_VOL, aux & 0x7fff); - else - rt5621_write(w->codec, RT5621_AUXIN_VOL, aux | 0x8000); - - if (l & 0x10 || r & 0x10) - rt5621_write(w->codec, RT5621_LINE_IN_VOL, lineIn & 0x7fff); - else - rt5621_write(w->codec, RT5621_LINE_IN_VOL, lineIn | 0x8000); - - return 0; -} - - -static int hp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - unsigned int reg = rt5621_read(codec, MISC_FUNC_REG); - - if (((reg & 0x03) != 0x00) && ((reg & 0x03) != 0x03)) - return 0; - - switch (event) - { - case SND_SOC_DAPM_POST_PMU: - hp_depop_mode2(codec); - rt5621_write_mask(codec, 0x04, 0x0000, 0x8080); - rt5621_write_mask(codec, 0x3a, 0x0020, 0x0020); - break; - case SND_SOC_DAPM_POST_PMD: - rt5621_write_mask(codec, 0x04, 0x8080, 0x8080); - rt5621_write_mask(codec, 0x3a, 0x0000, 0x0010); - rt5621_write_mask(codec, 0x3a, 0x0000, 0x0020); - rt5621_write_mask(codec, 0x3e, 0x0000, 0x0600); - break; - } - return 0; -} - -static int aux_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - unsigned int reg = rt5621_read(codec, MISC_FUNC_REG); - - if (((reg & 0x0c) != 0x00) && ((reg & 0x0c) != 0x0c)) - return 0; - - switch (event) - { - case SND_SOC_DAPM_POST_PMU: - aux_depop_mode2(codec); - rt5621_write_mask(codec, 0x06, 0x0000, 0x8080); - break; - case SND_SOC_DAPM_POST_PMD: - rt5621_write_mask(codec, 0x06, 0x8080, 0x8080); - rt5621_write_mask(codec, 0x3a, 0x0000, 0x0001); - rt5621_write_mask(codec, 0x3a, 0x0000, 0x0002); - rt5621_write_mask(codec, 0x3e, 0x0000, 0x6000); - break; - } - return 0; -} - -/* Left Headphone Mixers */ -static const struct snd_kcontrol_new rt5621_hpl_mixer_controls[] = { -SOC_DAPM_SINGLE("LineIn Playback Switch", HPL_MIXER, 4, 1, 0), -SOC_DAPM_SINGLE("AUXIN Playback Switch", HPL_MIXER, 3, 1, 0), -SOC_DAPM_SINGLE("Mic1 Playback Switch", HPL_MIXER, 2, 1, 0), -SOC_DAPM_SINGLE("Mic2 Playback Switch", HPL_MIXER, 1, 1, 0), -SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 0, 1, 0), -SOC_DAPM_SINGLE("RecordL Playback Switch", RT5621_ADC_REC_GAIN, 15, 1,1), -}; - -/* Right Headphone Mixers */ -static const struct snd_kcontrol_new rt5621_hpr_mixer_controls[] = { -SOC_DAPM_SINGLE("LineIn Playback Switch", HPR_MIXER, 4, 1, 0), -SOC_DAPM_SINGLE("AUXIN Playback Switch", HPR_MIXER, 3, 1, 0), -SOC_DAPM_SINGLE("Mic1 Playback Switch", HPR_MIXER, 2, 1, 0), -SOC_DAPM_SINGLE("Mic2 Playback Switch", HPR_MIXER, 1, 1, 0), -SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 0, 1, 0), -SOC_DAPM_SINGLE("RecordR Playback Switch", RT5621_ADC_REC_GAIN, 14, 1,1), -}; - -//Left Record Mixer -static const struct snd_kcontrol_new rt5621_captureL_mixer_controls[] = { -SOC_DAPM_SINGLE("Mic1 Capture Switch", RT5621_ADC_REC_MIXER, 14, 1, 1), -SOC_DAPM_SINGLE("Mic2 Capture Switch", RT5621_ADC_REC_MIXER, 13, 1, 1), -SOC_DAPM_SINGLE("LineInL Capture Switch",RT5621_ADC_REC_MIXER,12, 1, 1), -SOC_DAPM_SINGLE("AUXIN Capture Switch", RT5621_ADC_REC_MIXER, 11, 1, 1), -SOC_DAPM_SINGLE("HPMixerL Capture Switch", RT5621_ADC_REC_MIXER,10, 1, 1), -SOC_DAPM_SINGLE("SPKMixer Capture Switch",RT5621_ADC_REC_MIXER,9, 1, 1), -SOC_DAPM_SINGLE("MonoMixer Capture Switch",RT5621_ADC_REC_MIXER,8, 1, 1), -}; - - -//Right Record Mixer -static const struct snd_kcontrol_new rt5621_captureR_mixer_controls[] = { -SOC_DAPM_SINGLE("Mic1 Capture Switch", RT5621_ADC_REC_MIXER, 6, 1, 1), -SOC_DAPM_SINGLE("Mic2 Capture Switch", RT5621_ADC_REC_MIXER, 5, 1, 1), -SOC_DAPM_SINGLE("LineInR Capture Switch",RT5621_ADC_REC_MIXER,4, 1, 1), -SOC_DAPM_SINGLE("AUXIN Capture Switch", RT5621_ADC_REC_MIXER, 3, 1, 1), -SOC_DAPM_SINGLE("HPMixerR Capture Switch", RT5621_ADC_REC_MIXER,2, 1, 1), -SOC_DAPM_SINGLE("SPKMixer Capture Switch",RT5621_ADC_REC_MIXER,1, 1, 1), -SOC_DAPM_SINGLE("MonoMixer Capture Switch",RT5621_ADC_REC_MIXER,0, 1, 1), -}; - -/* Speaker Mixer */ -static const struct snd_kcontrol_new rt5621_speaker_mixer_controls[] = { -SOC_DAPM_SINGLE("LineIn Playback Switch", RT5621_LINE_IN_VOL, 14, 1, 1), -SOC_DAPM_SINGLE("AUXIN Playback Switch", RT5621_AUXIN_VOL, 14, 1, 1), -SOC_DAPM_SINGLE("Mic1 Playback Switch", RT5621_MIC_ROUTING_CTRL, 14, 1, 1), -SOC_DAPM_SINGLE("Mic2 Playback Switch", RT5621_MIC_ROUTING_CTRL, 6, 1, 1), -SOC_DAPM_SINGLE("PCM Playback Switch", RT5621_STEREO_DAC_VOL, 14, 1, 1), -}; - - -/* Mono Mixer */ -static const struct snd_kcontrol_new rt5621_mono_mixer_controls[] = { -SOC_DAPM_SINGLE("LineIn Playback Switch", RT5621_LINE_IN_VOL, 13, 1, 1), -SOC_DAPM_SINGLE("Mic1 Playback Switch", RT5621_MIC_ROUTING_CTRL, 13, 1, 1), -SOC_DAPM_SINGLE("Mic2 Playback Switch", RT5621_MIC_ROUTING_CTRL, 5, 1, 1), -SOC_DAPM_SINGLE("AUXIN Playback Switch", RT5621_AUXIN_VOL, 13, 1, 1), -SOC_DAPM_SINGLE("PCM Playback Switch", RT5621_STEREO_DAC_VOL, 13, 1, 1), -SOC_DAPM_SINGLE("RecordL Playback Switch", RT5621_ADC_REC_GAIN, 13, 1,1), -SOC_DAPM_SINGLE("RecordR Playback Switch", RT5621_ADC_REC_GAIN, 12, 1,1), -}; - -/* mono output mux */ -static const struct snd_kcontrol_new rt5621_mono_mux_controls = -SOC_DAPM_ENUM("Route", rt5621_enum[4]); - -/* speaker left output mux */ -static const struct snd_kcontrol_new rt5621_hp_spk_mux_controls = -SOC_DAPM_ENUM("Route", rt5621_enum[1]); - - -/* headphone left output mux */ -static const struct snd_kcontrol_new rt5621_hpl_out_mux_controls = -SOC_DAPM_ENUM("Route", rt5621_enum[2]); - -/* headphone right output mux */ -static const struct snd_kcontrol_new rt5621_hpr_out_mux_controls = -SOC_DAPM_ENUM("Route", rt5621_enum[3]); - -static const struct snd_soc_dapm_widget rt5621_dapm_widgets[] = { -SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 0, 0, - &rt5621_mono_mux_controls), -SND_SOC_DAPM_MUX("Speaker Out Mux", SND_SOC_NOPM, 0, 0, - &rt5621_hp_spk_mux_controls), -SND_SOC_DAPM_MUX("Left Headphone Out Mux", SND_SOC_NOPM, 0, 0, - &rt5621_hpl_out_mux_controls), -SND_SOC_DAPM_MUX("Right Headphone Out Mux", SND_SOC_NOPM, 0, 0, - &rt5621_hpr_out_mux_controls), - -SND_SOC_DAPM_MIXER_E("Left HP Mixer",RT5621_PWR_MANAG_ADD2, 5, 0, - &rt5621_hpl_mixer_controls[0], ARRAY_SIZE(rt5621_hpl_mixer_controls), - mixer_event, SND_SOC_DAPM_POST_REG), -SND_SOC_DAPM_MIXER_E("Right HP Mixer",RT5621_PWR_MANAG_ADD2, 4, 0, - &rt5621_hpr_mixer_controls[0], ARRAY_SIZE(rt5621_hpr_mixer_controls), - mixer_event, SND_SOC_DAPM_POST_REG), -SND_SOC_DAPM_MIXER("Mono Mixer", RT5621_PWR_MANAG_ADD2, 2, 0, - &rt5621_mono_mixer_controls[0], ARRAY_SIZE(rt5621_mono_mixer_controls)), - -SND_SOC_DAPM_MIXER("Speaker Mixer", RT5621_PWR_MANAG_ADD2,3,0, - &rt5621_speaker_mixer_controls[0], ARRAY_SIZE(rt5621_speaker_mixer_controls)), - -SND_SOC_DAPM_MIXER("Left Record Mixer", RT5621_PWR_MANAG_ADD2,1,0, - &rt5621_captureL_mixer_controls[0], ARRAY_SIZE(rt5621_captureL_mixer_controls)), -SND_SOC_DAPM_MIXER("Right Record Mixer", RT5621_PWR_MANAG_ADD2,0,0, - &rt5621_captureR_mixer_controls[0], ARRAY_SIZE(rt5621_captureR_mixer_controls)), - -SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", RT5621_PWR_MANAG_ADD2,9, 0), -SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", RT5621_PWR_MANAG_ADD2, 8, 0), - -SND_SOC_DAPM_MIXER("IIS Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), -SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), - -SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), -SND_SOC_DAPM_MIXER("AUXIN Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), - -SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", RT5621_PWR_MANAG_ADD2, 7, 0), -SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", RT5621_PWR_MANAG_ADD2, 6, 0), - -SND_SOC_DAPM_PGA_E("Left Headphone", MISC_FUNC_REG, 0, 0, NULL, 0, - hp_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), -SND_SOC_DAPM_PGA_E("Right Headphone", MISC_FUNC_REG, 1, 0, NULL, 0, - hp_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), - -SND_SOC_DAPM_PGA("Speaker PGA", RT5621_PWR_MANAG_ADD3, 12, 0, NULL, 0), - -SND_SOC_DAPM_PGA_E("AUXL Out", MISC_FUNC_REG, 2, 0, NULL, 0, - aux_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), -SND_SOC_DAPM_PGA_E("AUXR Out", MISC_FUNC_REG, 3, 0, NULL, 0, - aux_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), - -SND_SOC_DAPM_PGA("Left Line In", RT5621_PWR_MANAG_ADD3, 7, 0, NULL, 0), -SND_SOC_DAPM_PGA("Right Line In", RT5621_PWR_MANAG_ADD3, 6, 0, NULL, 0), -SND_SOC_DAPM_PGA("Left AUX In", RT5621_PWR_MANAG_ADD3, 5, 0, NULL, 0), -SND_SOC_DAPM_PGA("Right AUX In", RT5621_PWR_MANAG_ADD3, 4, 0, NULL, 0), - -SND_SOC_DAPM_PGA("Mic 1 PGA", RT5621_PWR_MANAG_ADD3, 3, 0, NULL, 0), -SND_SOC_DAPM_PGA("Mic 2 PGA", RT5621_PWR_MANAG_ADD3, 2, 0, NULL, 0), -SND_SOC_DAPM_PGA("Mic 1 Pre Amp", RT5621_PWR_MANAG_ADD3, 1, 0, NULL, 0), -SND_SOC_DAPM_PGA("Mic 2 Pre Amp", RT5621_PWR_MANAG_ADD3, 0, 0, NULL, 0), - -SND_SOC_DAPM_MICBIAS("Mic Bias1", RT5621_PWR_MANAG_ADD1, 11, 0), - -SND_SOC_DAPM_OUTPUT("AUXL"), -SND_SOC_DAPM_OUTPUT("AUXR"), -SND_SOC_DAPM_OUTPUT("HPL"), -SND_SOC_DAPM_OUTPUT("HPR"), -SND_SOC_DAPM_OUTPUT("SPK"), - -SND_SOC_DAPM_INPUT("LINEL"), -SND_SOC_DAPM_INPUT("LINER"), -SND_SOC_DAPM_INPUT("AUXINL"), -SND_SOC_DAPM_INPUT("AUXINR"), -SND_SOC_DAPM_INPUT("MIC1"), -SND_SOC_DAPM_INPUT("MIC2"), -SND_SOC_DAPM_VMID("VMID"), -}; - -static const struct snd_soc_dapm_route audio_map[] = { - /* left HP mixer */ - {"Left HP Mixer" , "LineIn Playback Switch" , "Left Line In"}, - {"Left HP Mixer" , "AUXIN Playback Switch" , "Left AUX In"}, - {"Left HP Mixer" , "Mic1 Playback Switch" , "Mic 1 PGA"}, - {"Left HP Mixer" , "Mic2 Playback Switch" , "Mic 2 PGA"}, - {"Left HP Mixer" , "PCM Playback Switch" , "Left DAC"}, - {"Left HP Mixer" , "RecordL Playback Switch" , "Left Record Mixer"}, - - /* right HP mixer */ - {"Right HP Mixer" , "LineIn Playback Switch" , "Right Line In"}, - {"Right HP Mixer" , "AUXIN Playback Switch" , "Right AUX In"}, - {"Right HP Mixer" , "Mic1 Playback Switch" , "Mic 1 PGA"}, - {"Right HP Mixer" , "Mic2 Playback Switch" , "Mic 2 PGA"}, - {"Right HP Mixer" , "PCM Playback Switch" , "Right DAC"}, - {"Right HP Mixer" , "RecordR Playback Switch" , "Right Record Mixer"}, - - /* virtual mixer - mixes left & right channels for spk and mono */ - {"IIS Mixer" , NULL , "Left DAC"}, - {"IIS Mixer" , NULL , "Right DAC"}, - {"Line Mixer" , NULL , "Right Line In"}, - {"Line Mixer" , NULL , "Left Line In"}, - {"AUXIN Mixer" , NULL , "Left AUX In"}, - {"AUXIN Mixer" , NULL , "Right AUX In"}, - {"HP Mixer" , NULL , "Left HP Mixer"}, - {"HP Mixer" , NULL , "Right HP Mixer"}, - - /* speaker mixer */ - {"Speaker Mixer" , "LineIn Playback Switch" , "Line Mixer"}, - {"Speaker Mixer" , "AUXIN Playback Switch" , "AUXIN Mixer"}, - {"Speaker Mixer" , "Mic1 Playback Switch" , "Mic 1 PGA"}, - {"Speaker Mixer" , "Mic2 Playback Switch" , "Mic 2 PGA"}, - {"Speaker Mixer" , "PCM Playback Switch" , "IIS Mixer"}, - - - /* mono mixer */ - {"Mono Mixer" , "LineIn Playback Switch" , "Line Mixer"}, - {"Mono Mixer" , "Mic1 Playback Switch" , "Mic 1 PGA"}, - {"Mono Mixer" , "Mic2 Playback Switch" , "Mic 2 PGA"}, - {"Mono Mixer" , "PCM Playback Switch" , "IIS Mixer"}, - {"Mono Mixer" , "AUXIN Playback Switch" , "AUXIN Mixer"}, - {"Mono Mixer" , "RecordL Playback Switch" , "Left Record Mixer"}, - {"Mono Mixer" , "RecordR Playback Switch" , "Right Record Mixer"}, - - /*Left record mixer */ - {"Left Record Mixer" , "Mic1 Capture Switch" , "Mic 1 Pre Amp"}, - {"Left Record Mixer" , "Mic2 Capture Switch" , "Mic 2 Pre Amp"}, - {"Left Record Mixer" , "LineInL Capture Switch" , "LINEL"}, - {"Left Record Mixer" , "AUXIN Capture Switch" , "AUXINL"}, - {"Left Record Mixer" , "HPMixerL Capture Switch" , "Left HP Mixer"}, - {"Left Record Mixer" , "SPKMixer Capture Switch" , "Speaker Mixer"}, - {"Left Record Mixer" , "MonoMixer Capture Switch" , "Mono Mixer"}, - - /*Right record mixer */ - {"Right Record Mixer" , "Mic1 Capture Switch" , "Mic 1 Pre Amp"}, - {"Right Record Mixer" , "Mic2 Capture Switch" , "Mic 2 Pre Amp"}, - {"Right Record Mixer" , "LineInR Capture Switch" , "LINER"}, - {"Right Record Mixer" , "AUXIN Capture Switch" , "AUXINR"}, - {"Right Record Mixer" , "HPMixerR Capture Switch" , "Right HP Mixer"}, - {"Right Record Mixer" , "SPKMixer Capture Switch" , "Speaker Mixer"}, - {"Right Record Mixer" , "MonoMixer Capture Switch" , "Mono Mixer"}, - - /* headphone left mux */ - {"Left Headphone Out Mux" , "HPL mixer" , "Left HP Mixer"}, - - /* headphone right mux */ - {"Right Headphone Out Mux", "HPR mixer", "Right HP Mixer"}, - - /* speaker mux */ - {"Speaker Out Mux", "HP mixer", "HP Mixer"}, - {"Speaker Out Mux", "SPK mixer", "Speaker Mixer"}, - {"Speaker Out Mux", "Mono Mixer", "Mono Mixer"}, - - /* mono mux */ - {"Mono Out Mux", "HP mixer", "HP Mixer"}, - {"Mono Out Mux", "SPK mixer", "Speaker Mixer"}, - {"Mono Out Mux", "Mono Mixer", "Mono Mixer"}, - - /* output pga */ - {"HPL", NULL, "Left Headphone"}, - {"Left Headphone", NULL, "Left Headphone Out Mux"}, - - {"HPR", NULL, "Right Headphone"}, - {"Right Headphone", NULL, "Right Headphone Out Mux"}, - - {"SPK", NULL, "Speaker PGA"}, - {"Speaker PGA", NULL, "Speaker Out Mux"}, - - {"AUXL", NULL, "AUXL Out"}, - {"AUXL Out", NULL, "Mono Out Mux"}, - - {"AUXR", NULL, "AUXR Out"}, - {"AUXR Out", NULL, "Mono Out Mux"}, - - /* input pga */ - {"Left Line In", NULL, "LINEL"}, - {"Right Line In", NULL, "LINER"}, - - {"Left AUX In", NULL, "AUXINL"}, - {"Right AUX In", NULL, "AUXINR"}, - - {"Mic 1 Pre Amp", NULL, "MIC1"}, - {"Mic 2 Pre Amp", NULL, "MIC2"}, - {"Mic 1 PGA", NULL, "Mic 1 Pre Amp"}, - {"Mic 2 PGA", NULL, "Mic 2 Pre Amp"}, - - /* left ADC */ - {"Left ADC", NULL, "Left Record Mixer"}, - - /* right ADC */ - {"Right ADC", NULL, "Right Record Mixer"}, - -}; - -static int rt5621_add_widgets(struct snd_soc_codec *codec) -{ - snd_soc_dapm_new_controls(codec, rt5621_dapm_widgets, - ARRAY_SIZE(rt5621_dapm_widgets)); - snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); - snd_soc_dapm_new_widgets(codec); - - return 0; -} - -#else - -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 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; -} - -#endif -/* 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}, //flove040711 - { 3072000, 12288000, 0x1ee0}, //flove040711 -}; - - -static int rt5621_set_dai_pll(struct snd_soc_dai *codec_dai, - int pll_id, unsigned int freq_in, unsigned int freq_out) -{ - int i; - int ret = -EINVAL; - struct snd_soc_codec *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) - { - rt5621_write_mask(codec, RT5621_GLOBAL_CLK_CTRL_REG, 0x0000, 0x4000); - rt5621_write(codec,RT5621_PLL_CTRL,codec_pll_div[i].regvalue);//set PLL parameter - rt5621_write_mask(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)) - { - rt5621_write_mask(codec, RT5621_GLOBAL_CLK_CTRL_REG, 0x4000, 0x4000); - rt5621_write(codec,RT5621_PLL_CTRL,codec_bclk_pll_div[i].regvalue);//set PLL parameter - rt5621_write_mask(codec,RT5621_PWR_MANAG_ADD2, 0x1000,0x1000); //enable PLL power - ret = 0; - } - } - } - - rt5621_write_mask(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}, - -}; - - - -static int get_coeff(int mclk, int rate) -{ - int i; - - printk("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 *codec_dai, - int clk_id, unsigned int freq, int dir) -{ - struct snd_soc_codec *codec = codec_dai->codec; - struct rt5621_priv *rt5621 = codec->private_data; - - switch (freq) { - case 24576000: - rt5621->sysclk = freq; - return 0; - } - return 0; -} - - -static int rt5621_set_dai_fmt(struct snd_soc_dai *codec_dai, - unsigned int fmt) -{ - struct snd_soc_codec *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; - } - - rt5621_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 *codec_dai) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev ->card->codec; - struct rt5621_priv *rt5621 = codec->private_data; - u16 iface=rt5621_read(codec,RT5621_AUDIO_INTERFACE)&0xfff3; - int coeff = get_coeff(rt5621->sysclk, params_rate(params)); - - printk("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 */ - rt5621_write(codec, RT5621_AUDIO_INTERFACE, iface); - - if (coeff >= 0) - rt5621_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; -} - -#if !USE_DAPM_CONTROL -static int rt5621_set_bias_level(struct snd_soc_codec *codec, - enum snd_soc_bias_level level) -{ - switch (level) { - case SND_SOC_BIAS_ON: - break; - case SND_SOC_BIAS_PREPARE: - break; - case SND_SOC_BIAS_STANDBY: - break; - case SND_SOC_BIAS_OFF: - - rt5621_write_mask(codec, 0x02, 0x8080, 0x8080); - rt5621_write_mask(codec, 0x04, 0x8080, 0x8080); - rt5621_write(codec, 0x3e, 0x0000); - rt5621_write(codec, 0x3c, 0x0000); - rt5621_write(codec, 0x3a, 0x0000); - break; - } - codec->bias_level = level; - return 0; -} -#else -static int rt5621_set_bias_level(struct snd_soc_codec *codec, - enum snd_soc_bias_level level) -{ - switch (level) { - case SND_SOC_BIAS_ON: - break; - case SND_SOC_BIAS_PREPARE: - break; - case SND_SOC_BIAS_STANDBY: - - break; - case SND_SOC_BIAS_OFF: - - rt5621_write_mask(codec, 0x02, 0x8080, 0x8080); - rt5621_write_mask(codec, 0x04, 0x8080, 0x8080); - rt5621_write(codec, 0x3e, 0x0000); - rt5621_write(codec, 0x3c, 0x0000); - rt5621_write(codec, 0x3a, 0x0000); - break; - } - codec->bias_level = level; - return 0; -} -#endif - - - - - -#if !USE_DAPM_CONTROL - -static void rt5621_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->card->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_ChangeCodecPowerStatus(codec,POWER_STATE_D2_PLAYBACK); //power off dac to hp and speaker out - - - - 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; - } -} - -#endif - - -#define RT5621_HIFI_RATES SNDRV_PCM_RATE_8000_48000 - -#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, -#if !USE_DAPM_CONTROL - .prepare = rt5621_pcm_hw_prepare, - .shutdown = rt5621_shutdown, -#endif - -}; - -struct snd_soc_dai rt5621_dai = { - - .name = "RT5621", - .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, -}; - - -EXPORT_SYMBOL_GPL(rt5621_dai); - -static ssize_t rt5621_index_reg_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct snd_soc_device *socdev = dev_get_drvdata(dev); - struct snd_soc_codec *codec = socdev ->card->codec; - int count = 0; - int value; - int i; - - count += sprintf(buf, "%s index register\n", codec->name); - - for (i = 0; i < 0x60; i++) { - count += sprintf(buf + count, "index-%2x ", i); - if (count >= PAGE_SIZE - 1) - break; - value = rt5621_read_index(codec, i); - count += snprintf(buf + count, PAGE_SIZE - count, "0x%4x", value); - - if (count >= PAGE_SIZE - 1) - break; - - count += snprintf(buf + count, PAGE_SIZE - count, "\n"); - if (count >= PAGE_SIZE - 1) - break; - } - - if (count >= PAGE_SIZE) - count = PAGE_SIZE - 1; - - return count; - -} - -static DEVICE_ATTR(index_reg, 0444, rt5621_index_reg_show, NULL); - -#if defined(CONFIG_SND_HWDEP) -#if REALTEK_HWDEP - -#define RT_CE_CODEC_HWDEP_NAME "rt56xx hwdep " - -static int rt56xx_hwdep_open(struct snd_hwdep *hw, struct file *file) -{ - printk("enter %s\n", __func__); - return 0; -} - -static int rt56xx_hwdep_release(struct snd_hwdep *hw, struct file *file) -{ - printk("enter %s\n", __func__); - return 0; -} - - -static int rt56xx_hwdep_ioctl_common(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) -{ - struct rt56xx_cmd rt56xx; - struct rt56xx_cmd __user *_rt56xx = arg; - struct rt56xx_reg_state *buf; - struct rt56xx_reg_state *p; - struct snd_soc_codec *codec = hw->private_data; - - if (copy_from_user(&rt56xx, _rt56xx, sizeof(rt56xx))) - return -EFAULT; - buf = kmalloc(sizeof(*buf) * rt56xx.number, GFP_KERNEL); - if (buf == NULL) - return -ENOMEM; - if (copy_from_user(buf, rt56xx.buf, sizeof(*buf) * rt56xx.number)) { - goto err; - } - switch (cmd) { - case RT_READ_CODEC_REG_IOCTL: - for (p = buf; p < buf + rt56xx.number; p++) - { - p->reg_value = codec->read(codec, p->reg_index); - } - if (copy_to_user(rt56xx.buf, buf, sizeof(*buf) * rt56xx.number)) - goto err; - - break; - case RT_WRITE_CODEC_REG_IOCTL: - for (p = buf; p < buf + rt56xx.number; p++) - codec->write(codec, p->reg_index, p->reg_value); - break; - } - - kfree(buf); - return 0; - -err: - kfree(buf); - return -EFAULT; - -} - -static int rt56xx_codec_dump_reg(struct snd_hwdep *hw, struct file *file, unsigned long arg) -{ - struct rt56xx_cmd rt56xx; - struct rt56xx_cmd __user *_rt56xx = arg; - struct rt56xx_reg_state *buf; - struct snd_soc_codec *codec = hw->private_data; - int number = codec->reg_cache_size; - int i; - - printk(KERN_DEBUG "enter %s, number = %d\n", __func__, number); - if (copy_from_user(&rt56xx, _rt56xx, sizeof(rt56xx))) - return -EFAULT; - - buf = kmalloc(sizeof(*buf) * number, GFP_KERNEL); - if (buf == NULL) - return -ENOMEM; - - for (i = 0; i < number; i++) - { - buf[i].reg_index = i << 1; - buf[i].reg_value = codec->read(codec, buf[i].reg_index); - } - if (copy_to_user(rt56xx.buf, buf, sizeof(*buf) * i)) - goto err; - rt56xx.number = number; - if (copy_to_user(_rt56xx, &rt56xx, sizeof(rt56xx))) - goto err; - kfree(buf); - return 0; -err: - kfree(buf); - return -EFAULT; - -} - -static int rt56xx_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) -{ - if (cmd == RT_READ_ALL_CODEC_REG_IOCTL) - { - return rt56xx_codec_dump_reg(hw, file, arg); - } - else - { - return rt56xx_hwdep_ioctl_common(hw, file, cmd, arg); - } -} - -static int realtek_ce_init_hwdep(struct snd_soc_codec *codec) -{ - struct snd_hwdep *hw; - struct snd_card *card = codec->card; - int err; - - if ((err = snd_hwdep_new(card, RT_CE_CODEC_HWDEP_NAME, 0, &hw)) < 0) - return err; - - strcpy(hw->name, RT_CE_CODEC_HWDEP_NAME); - hw->private_data = codec; - hw->ops.open = rt56xx_hwdep_open; - hw->ops.release = rt56xx_hwdep_release; - hw->ops.ioctl = rt56xx_hwdep_ioctl; - return 0; -} - -#endif -#endif - -static void rt5621_work(struct work_struct *work) -{ - struct snd_soc_codec *codec = - container_of(work, struct snd_soc_codec, delayed_work.work); - - rt5621_set_bias_level(codec, codec->bias_level); -} - - -static int rt5621_suspend(struct platform_device *pdev, pm_message_t state) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev ->card->codec; - - /* we only need to suspend if we are a valid card */ - if(!codec->card) - return 0; - - rt5621_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - return 0; -} - -static int rt5621_resume(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev ->card->codec; - int i; - u8 data[3]; - u16 *cache = codec->reg_cache; - - /* we only need to resume if we are a valid card */ - if(!codec->card) - return 0; - - /* Sync reg_cache with the hardware */ - - for (i = 0; i < ARRAY_SIZE(rt5621_reg); i++) { - if (i == RT5621_RESET) - continue; - data[0] =i << 1; - data[1] = (0xFF00 & cache[i]) >> 8; - data[2] = 0x00FF & cache[i]; - codec->hw_write(codec->control_data, data, 3); - } - - rt5621_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - - /* charge rt5621 caps */ - - if (codec->suspend_bias_level == SND_SOC_BIAS_ON) { - rt5621_set_bias_level(codec, SND_SOC_BIAS_PREPARE); - codec->bias_level = SND_SOC_BIAS_ON; - schedule_delayed_work(&codec->delayed_work, - msecs_to_jiffies(caps_charge)); - } - return 0; -} - - -/* - * initialise the RT5621 driver - * register the mixer and dsp interfaces with the kernel - */ -static int rt5621_init(struct snd_soc_device *socdev) -{ - struct snd_soc_codec *codec = socdev ->card->codec; - int ret = 0; - - printk(KERN_INFO "alsa version is 1.0.21, codec driver version is 0.04\n"); - codec->name = "RT5621"; - codec->owner = THIS_MODULE; - codec->read = rt5621_read; - codec->write = rt5621_write; - codec->set_bias_level = rt5621_set_bias_level; - codec->dai = &rt5621_dai; - codec->num_dai = 1; - codec->reg_cache_step = 2; - codec->reg_cache_size = ARRAY_SIZE(rt5621_reg) * 2; - codec->reg_cache = kmemdup(rt5621_reg, sizeof(rt5621_reg), GFP_KERNEL); - - if (codec->reg_cache == NULL) - return -ENOMEM; - - /* register pcms */ - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); - if (ret < 0) { - printk(KERN_ERR "rt5621: failed to create pcms\n"); - goto pcm_err; - } - - - rt5621_reset(codec); - rt5621_write(codec, RT5621_PWR_MANAG_ADD3, 0x8000);//enable Main bias - rt5621_write(codec, RT5621_PWR_MANAG_ADD2, 0x2000);//enable Vref - - hp_depop_mode2(codec); - - rt5621_init_reg(codec); - rt5621_set_bias_level(codec, SND_SOC_BIAS_PREPARE); - codec->bias_level = SND_SOC_BIAS_STANDBY; - schedule_delayed_work(&codec->delayed_work, - msecs_to_jiffies(caps_charge)); - - rt5621_add_controls(codec); - - #if USE_DAPM_CONTROL - - rt5621_add_widgets(codec); - - #endif - - #if defined(CONFIG_SND_HWDEP) - #if REALTEK_HWDEP - - realtek_ce_init_hwdep(codec); - - #endif - #endif - - ret = snd_soc_init_card(socdev); - - if (ret < 0) { - printk(KERN_ERR "rt5621: failed to register card\n"); - goto card_err; - } - return ret; - -card_err: - snd_soc_free_pcms(socdev); - snd_soc_dapm_free(socdev); -pcm_err: - kfree(codec->reg_cache); - return ret; -} - -static int rt5621_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) -{ - struct snd_soc_device *socdev = rt5621_socdev; - struct snd_soc_codec *codec = socdev ->card->codec; - int ret; - - i2c_set_clientdata(i2c, codec); - codec->control_data = i2c; - - ret = rt5621_init(socdev); - if (ret < 0) - pr_err("failed to initialise rt5621\n"); - - return ret; -} - - -static int rt5621_i2c_remove(struct i2c_client *client) -{ - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); - return 0; -} - -static const struct i2c_device_id rt5621_i2c_id[] = { - {"ALC5621", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, rt5621_i2c_id); -static struct i2c_driver rt5621_i2c_driver = { - .driver = { - .name = "RT5621 I2C Codec", - .owner = THIS_MODULE, - }, - .probe = rt5621_i2c_probe, - .remove = rt5621_i2c_remove, - .id_table = rt5621_i2c_id, -}; - -static int rt5621_add_i2c_device(struct platform_device *pdev, - const struct rt5621_setup_data *setup) -{ -#if 0 - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; -#endif - int ret; - ret = i2c_add_driver(&rt5621_i2c_driver); - if (ret != 0) { - dev_err(&pdev->dev, "can't add i2c driver\n"); - return ret; - } -#if 0 - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = setup->i2c_address; - strlcpy(info.type, "rt5621", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(setup->i2c_bus); - if (!adapter) { - dev_err(&pdev->dev, "can't get i2c adapter %d\n", - setup->i2c_bus); - goto err_driver; - } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - goto err_driver; - } -#endif - return 0; - -#if 0 -err_driver: - i2c_del_driver(&rt5621_i2c_driver); - return -ENODEV; -#endif -} - - -static int rt5621_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct rt5621_setup_data *setup = socdev->codec_data; - struct snd_soc_codec *codec; - struct rt5621_priv *rt5621; - int ret; - - pr_info("RT5621 Audio Codec %s\n", RT5621_VERSION); - - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) - return -ENOMEM; - - rt5621 = kzalloc(sizeof(struct rt5621_priv), GFP_KERNEL); - if (rt5621 == NULL) { - kfree(codec); - return -ENOMEM; - } - codec->private_data = rt5621; - socdev ->card->codec = codec; - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - rt5621_socdev = socdev; - INIT_DELAYED_WORK(&codec->delayed_work, rt5621_work); - ret = device_create_file(&pdev->dev, &dev_attr_index_reg); - if (ret < 0) - printk(KERN_WARNING "asoc: failed to add index_reg sysfs files\n"); - - ret = -ENODEV; -// if (setup->i2c_address) { - codec->hw_write = (hw_write_t)i2c_master_send; - ret = rt5621_add_i2c_device(pdev, setup); -// } - if (ret != 0) { - kfree(codec->private_data); - kfree(codec); - } - return ret; -} - -static int run_delayed_work(struct delayed_work *dwork) -{ - int ret; - - /* cancel any work waiting to be queued. */ - ret = cancel_delayed_work(dwork); - - /* if there was any work waiting then we run it now and - * wait for it's completion */ - if (ret) { - schedule_delayed_work(dwork, 0); - flush_scheduled_work(); - } - return ret; -} - -static int rt5621_remove(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev ->card->codec; - - if (codec->control_data) - rt5621_set_bias_level(codec, SND_SOC_BIAS_OFF); - run_delayed_work(&codec->delayed_work); - snd_soc_free_pcms(socdev); - snd_soc_dapm_free(socdev); - device_remove_file(&pdev->dev, &dev_attr_index_reg); - i2c_unregister_device(codec->control_data); - i2c_del_driver(&rt5621_i2c_driver); - kfree(codec->private_data); - kfree(codec); - - return 0; -} - -struct snd_soc_codec_device soc_codec_dev_rt5621 = { - .probe = rt5621_probe, - .remove = rt5621_remove, - .suspend = rt5621_suspend, - .resume = rt5621_resume, -}; - -EXPORT_SYMBOL_GPL(soc_codec_dev_rt5621); - -static int __init rt5621_modinit(void) -{ - return snd_soc_register_dai(&rt5621_dai); -} - -static void __exit rt5621_exit(void) -{ - snd_soc_unregister_dai(&rt5621_dai); -} - -module_init(rt5621_modinit); -module_exit(rt5621_exit); -MODULE_LICENSE("GPL"); - diff --git a/sound/soc/codecs/rt5621.c b/sound/soc/codecs/rt5621.c new file mode 100644 index 000000000000..c0ee91b3f40e --- /dev/null +++ b/sound/soc/codecs/rt5621.c @@ -0,0 +1,1221 @@ +/* + * rt5621.c -- RT5621 ALSA SoC audio codec driver + * + * Copyright 2011 Realtek Semiconductor Corp. + * Author: Johnny Hsu + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rt5621.h" + +#if REALTEK_HWDEP +#include +#include +#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 "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/alc5621.h b/sound/soc/codecs/rt5621.h similarity index 95% rename from sound/soc/codecs/alc5621.h rename to sound/soc/codecs/rt5621.h index bdcebbdbe114..9c1459c89360 100644 --- a/sound/soc/codecs/alc5621.h +++ b/sound/soc/codecs/rt5621.h @@ -1,516 +1,515 @@ -#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) - - -struct rt5621_setup_data { - unsigned short i2c_address; - unsigned short i2c_bus; -}; - - - -#define RT5621_PLL_FR_MCLK 0 -#define RT5621_PLL_FR_BCLK 1 - - -#define USE_DAPM_CONTROL 0 -#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 - -extern struct snd_soc_dai rt5621_dai; -extern struct snd_soc_codec_device soc_codec_dev_rt5621; - -#endif +/* + * rt5621.h -- RT5621 ALSA SoC audio driver + * + * Copyright 2011 Realtek Microelectronics + * Author: Johnny Hsu + * + * 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__ */ diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c old mode 100644 new mode 100755 index 9b5d72587aa1..09e132db93a6 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -1,7 +1,7 @@ /* * rt5631.c -- RT5631 ALSA Soc Audio driver * - * Copyright 2009 Realtek Microelectronics + * Copyright 2011 Realtek Microelectronics * * Author: flove * @@ -30,253 +30,191 @@ #include "rt5631.h" #include -#if 1 +#if 0 #define DBG(x...) printk(x) #else #define DBG(x...) #endif +#define RT5631_VERSION "0.01 alsa 1.0.24" -#define RT5631_VERSION "0.02 alsa 1.0.21" -#define ALSA_SOC_VERSION "1.0.21" -static const u16 rt5631_reg[0x80]; -static int timesofbclk = 32; -module_param(timesofbclk, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); -MODULE_PARM_DESC(timeofbclk, "relationship between bclk and fs"); - -#define RT5631_ALC_DAC_FUNC_ENA 0 //ALC functio for DAC +#define RT5631_ALC_DAC_FUNC_ENA 1 //ALC functio for DAC #define RT5631_ALC_ADC_FUNC_ENA 1 //ALC function for ADC -#define RT5631_EQ_FUNC_ENA 1 -#define RT5631_SPK_TIMER 1 //if enable this, MUST enable RT5631_EQ_FUNC_ENA first! - -#define VIRTUAL_POWER_CONTROL 0x90 -/* - * bit0: spkl amp power - * bit1: spkr amp power - * bit2: dmic flag - * bit[4~7] for EQ function - * bit[8] for dacl->hpl - * bit[9] for dacr->hpr +#define RT5631_SPK_TIMER 0 //if enable this, MUST enable RT5631_EQ_FUNC_ENA first! - * -*/ struct rt5631_priv { + int codec_version; int master; int sysclk; - int dmic_used_flag; + int dmic_used_flag; + int eq_mode; + int pll_used_flag; }; #if (RT5631_SPK_TIMER == 1) static struct timer_list spk_timer; struct work_struct spk_work; static bool last_is_spk = false; // need modify. #endif -static unsigned int reg90; -static int rt5631_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int val); -static unsigned int rt5631_read(struct snd_soc_codec *codec, unsigned int reg); -#define rt5631_reset(c) rt5631_write(c, RT5631_RESET, 0) -//#define rt5631_write_mask(c, reg, val, mask) snd_soc_update_bits(c, reg, mask, val) -static int rt5631_reg_init(struct snd_soc_codec *codec); -static struct snd_soc_device *rt5631_socdev; -/* - * read rt5631 register cache - */ -static inline unsigned int rt5631_read_reg_cache(struct snd_soc_codec *codec, - unsigned int reg) +static struct snd_soc_codec *rt5631_codec; +static const u16 rt5631_reg[0x80]; +static int timesofbclk = 32; +bool isPlaybackon = false, isCaptureon = false; + +module_param(timesofbclk, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); +MODULE_PARM_DESC(timeofbclk, "relationship between bclk and fs"); + + +static inline int rt5631_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int val) { - u16 *cache = codec->reg_cache; - if (reg < 1 || reg > (ARRAY_SIZE(rt5631_reg) + 1)) - return -1; - return cache[reg]; + return snd_soc_write(codec, reg, val); } - -/* - * write rt5631 register cache - */ - -static inline void rt5631_write_reg_cache(struct snd_soc_codec *codec, - unsigned int reg, unsigned int value) +static inline unsigned int rt5631_read(struct snd_soc_codec *codec, + unsigned int reg) { - u16 *cache = codec->reg_cache; - if (reg < 0 || reg > 0x7e) - return; - cache[reg] = value; + return snd_soc_read(codec, reg); } -static int rt5631_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int val) +static int rt5631_write_mask(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value, unsigned int mask) { - u8 data[3]; - - if (reg > 0x7e) { - if (reg == 0x90) - reg90 = val; + unsigned int reg_val; + int ret = 0; + + if (!mask) return 0; - } - - data[0] = reg; - data[1] = (0xff00 & val) >> 8; - data[2] = (0xff & val); - - if (codec->hw_write(codec->control_data, data, 3) == 3) { - rt5631_write_reg_cache(codec, reg, val); - DBG(KERN_INFO "%s reg=0x%x, val=0x%x\n", __func__, reg, val); - return 0; + + if (mask != 0xffff) { + reg_val = rt5631_read(codec, reg); + reg_val &= ~mask; + reg_val |= (value & mask); + ret = rt5631_write(codec, reg, reg_val); } else { - DBG(KERN_ERR "%s failed\n", __func__); - return -EIO; - } -} - -static unsigned int rt5631_read(struct snd_soc_codec *codec, unsigned int reg) -{ - u8 data[2] = {0}; - unsigned int value = 0x0; - - if (reg > 0x7e) { - if (reg == 0x90) - return reg90; - } - - data[0] = reg; - - i2c_master_reg8_recv(codec->control_data,reg,data,2,100 * 1000); - - value = (data[0]<<8) | data[1]; - - //DBG("rt5631_read reg%x=%x\n",reg,value); - - return value; -} - - -int rt5631_write_mask(struct snd_soc_codec *codec, unsigned int reg,unsigned int value,unsigned int mask) -{ - - unsigned char RetVal=0; - unsigned int CodecData; - -// DBG(KERN_INFO "rt5631_write_mask ok, reg = %x, value = %x ,mask= %x\n", reg, value,mask); - - if(!mask) - return 0; - - if(mask!=0xffff) - { - CodecData=rt5631_read(codec,reg); - CodecData&=~mask; - CodecData|=(value&mask); - RetVal=rt5631_write(codec,reg,CodecData); - } - else - { - RetVal=rt5631_write(codec,reg,value); + ret = rt5631_write(codec, reg, value); } - return RetVal; + return ret; } - -void rt5631_write_index(struct snd_soc_codec *codec, unsigned int reg, - unsigned int value) +static void rt5631_write_index(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value) { - - rt5631_write(codec,0x6a,reg); - rt5631_write(codec,0x6c,value); + rt5631_write(codec, RT5631_INDEX_ADD, reg); + rt5631_write(codec, RT5631_INDEX_DATA, value); + return; } -unsigned int rt5631_read_index(struct snd_soc_codec *codec, unsigned int reg) +static unsigned int rt5631_read_index(struct snd_soc_codec *codec, + unsigned int reg) { - unsigned int value = 0x0; - rt5631_write(codec,0x6a,reg); - value=rt5631_read(codec,0x6c); - + unsigned int value; + + rt5631_write(codec, RT5631_INDEX_ADD, reg); + value = rt5631_read(codec, RT5631_INDEX_DATA); + return value; } -void rt5631_write_index_mask(struct snd_soc_codec *codec, unsigned int reg,unsigned int value,unsigned int mask) +static void rt5631_write_index_mask(struct snd_soc_codec *codec, + unsigned int reg, unsigned int value, unsigned int mask) { - -// unsigned char RetVal=0; - unsigned int CodecData; + unsigned int reg_val; -// DBG(KERN_INFO "rt5631_write_index_mask ok, reg = %x, value = %x ,mask= %x\n", reg, value,mask); + if (!mask) + return; - if(!mask) - return; - - if(mask!=0xffff) - { - CodecData=rt5631_read_index(codec,reg); - CodecData&=~mask; - CodecData|=(value&mask); - rt5631_write_index(codec,reg,CodecData); - } - else - { - rt5631_write_index(codec,reg,value); + if (mask != 0xffff) { + reg_val = rt5631_read_index(codec, reg); + reg_val &= ~mask; + reg_val |= (value & mask); + rt5631_write_index(codec, reg, reg_val); + } else { + rt5631_write_index(codec, reg, value); } + + return; } -struct rt5631_init_reg{ +static inline int rt5631_reset(struct snd_soc_codec *codec) +{ + return snd_soc_write(codec, RT5631_RESET, 0); +} + +struct rt5631_init_reg { u8 reg; u16 val; }; #ifndef DEF_VOL -#define DEF_VOL 0xc0 +#define DEF_VOL 0xd4//0xd4 -30dB 0xc0 0dB #endif #ifndef DEF_VOL_SPK #define DEF_VOL_SPK 0xc4 #endif +/* + * speaker channel volume select SPKMIXER, 0DB by default + * Headphone channel volume select OUTMIXER,0DB by default + * AXO1/AXO2 channel volume select OUTMIXER,0DB by default + * Record Mixer source from Mic1/Mic2 by default + * Mic1/Mic2 boost 40dB by default + * DAC_L-->OutMixer_L by default + * DAC_R-->OutMixer_R by default + * DAC-->SpeakerMixer + * Speaker volume-->SPOMixer(L-->L,R-->R) + * Speaker AMP ratio gain is 1.44X + * HP from OutMixer,speaker out from SpeakerOut Mixer + * enable HP zero cross + * change Mic1 & mic2 to differential mode + */ static struct rt5631_init_reg init_list[] = { - {RT5631_SPK_OUT_VOL , (DEF_VOL_SPK<<8) | DEF_VOL_SPK}, //speaker channel volume select SPKMIXER,0DB by default - {RT5631_HP_OUT_VOL , (DEF_VOL<<8) | DEF_VOL}, //Headphone channel volume select OUTMIXER,0DB by default - {RT5631_MONO_AXO_1_2_VOL , 0xf0c0}, //AXO1/AXO2 channel volume select OUTMIXER,0DB by default - {RT5631_ADC_REC_MIXER , 0xb0f0}, //Record Mixer source from Mic1 by default - {RT5631_ADC_CTRL_1 , 0x0006},//STEREO ADC CONTROL 1 - {RT5631_MIC_CTRL_2 , 0x6600},//0x8800},//0x5500}, //Mic1/Mic2 boost 40DB by default + {RT5631_SPK_OUT_VOL , (DEF_VOL_SPK<<8) | DEF_VOL_SPK},//speaker channel volume select SPKMIXER,0DB by default + {RT5631_HP_OUT_VOL , (DEF_VOL<<8) | DEF_VOL},//Headphone channel volume select OUTMIXER,0DB by default + {RT5631_MONO_AXO_1_2_VOL , 0xf0c0},//AXO1/AXO2 channel volume select OUTMIXER,0DB by default + //{RT5631_STEREO_DAC_VOL_1 , 0x004C}, + {RT5631_ADC_REC_MIXER , 0xb0f0},//Record Mixer source from Mic1 by default + {RT5631_ADC_CTRL_1 , 0x0006},//STEREO ADC CONTROL 1 + {RT5631_MIC_CTRL_2 , 0x6600},//0x8800},//0x5500}, //Mic1/Mic2 boost 40DB by default + {RT5631_PWR_MANAG_ADD1 , 0x93e0}, #if RT5631_ALC_ADC_FUNC_ENA - {RT5631_ALC_CTRL_1 , 0x0a0f},//ALC CONTROL 1 - {RT5631_ALC_CTRL_2 , 0x0005},//ALC CONTROL 2 - {RT5631_ALC_CTRL_3 , 0xe080},//ALC CONTROL 3 + {RT5631_ALC_CTRL_1 , 0x0a0f},//ALC CONTROL 1 + {RT5631_ALC_CTRL_2 , 0x0005},//ALC CONTROL 2 + {RT5631_ALC_CTRL_3 , 0xe080},//ALC CONTROL 3 #endif - {RT5631_OUTMIXER_L_CTRL , 0xdfC0}, //DAC_L-->OutMixer_L by default - {RT5631_OUTMIXER_R_CTRL , 0xdfC0}, //DAC_R-->OutMixer_R by default - {RT5631_AXO1MIXER_CTRL , 0x8840}, //OutMixer_L-->AXO1Mixer by default - {RT5631_AXO2MIXER_CTRL , 0x8880}, //OutMixer_R-->AXO2Mixer by default - {RT5631_SPK_MIXER_CTRL , 0xd8d8}, //DAC-->SpeakerMixer - {RT5631_SPK_MONO_OUT_CTRL , 0x6c00}, //Speaker volume-->SPOMixer(L-->L,R-->R) - {RT5631_GEN_PUR_CTRL_REG , 0x2e00}, //Speaker AMP ratio gain is 1.27x + {RT5631_OUTMIXER_L_CTRL , 0xdfC0},//DAC_L-->OutMixer_L by default + {RT5631_OUTMIXER_R_CTRL , 0xdfC0},//DAC_R-->OutMixer_R by default + {RT5631_AXO1MIXER_CTRL , 0x8840},//OutMixer_L-->AXO1Mixer by default + {RT5631_AXO2MIXER_CTRL , 0x8880},//OutMixer_R-->AXO2Mixer by default + {RT5631_SPK_MIXER_CTRL , 0xd8d8},//DAC-->SpeakerMixer + {RT5631_SPK_MONO_OUT_CTRL , 0x6c00},//Speaker volume-->SPOMixer(L-->L,R-->R) + {RT5631_GEN_PUR_CTRL_REG , 0x4e00},//Speaker AMP ratio gain is 1.27x #if defined(CONFIG_ADJUST_VOL_BY_CODEC) - {RT5631_SPK_MONO_HP_OUT_CTRL, 0x0000}, //HP from outputmixer,speaker out from SpeakerOut Mixer + {RT5631_SPK_MONO_HP_OUT_CTRL , 0x0000},//HP from outputmixer,speaker out from SpeakerOut Mixer #else - {RT5631_SPK_MONO_HP_OUT_CTRL, 0x000c}, //HP from DAC,speaker out from SpeakerOut Mixer + {RT5631_SPK_MONO_HP_OUT_CTRL , 0x000c},//HP from DAC,speaker out from SpeakerOut Mixer #endif - {RT5631_DEPOP_FUN_CTRL_2 , 0x8000}, //HP depop by register control - {RT5631_INT_ST_IRQ_CTRL_2 , 0x0f18}, //enable HP zero cross - {RT5631_MIC_CTRL_1 , 0x8000}, //set mic 1 to differnetial mode - {RT5631_GPIO_CTRL , 0x0000}, //set GPIO to input pin -// {RT5631_JACK_DET_CTRL , 0x4e80}, //Jack detect for GPIO,high is HP,low is speaker - {RT5631_JACK_DET_CTRL , 0x4bc0}, //Jack detect for GPIO,high is speaker,low is hp + {RT5631_DEPOP_FUN_CTRL_2 , 0x8000},//HP depop by register control + {RT5631_INT_ST_IRQ_CTRL_2 , 0x0f18},//enable HP zero cross + {RT5631_MIC_CTRL_1 , 0x8000},//set mic 1 to differnetial mode + {RT5631_GPIO_CTRL , 0x0000},//set GPIO to input pin +// {RT5631_JACK_DET_CTRL , 0x4e80},//Jack detect for GPIO,high is HP,low is speaker + {RT5631_JACK_DET_CTRL , 0x4bc0},//Jack detect for GPIO,high is speaker,low is hp }; +#define RT5631_INIT_REG_LEN ARRAY_SIZE(init_list) -#define RT5631_INIT_REG_LEN ARRAY_SIZE(init_list) - -//************************************************************************************************* -//************************************************************************************************* -#if (RT5631_EQ_FUNC_ENA==1) -//EQ parameter -enum -{ - NORMAL=0, +/* + * EQ parameter + */ +enum { + NORMAL, CLUB, DANCE, - LIVE, + LIVE, POP, ROCK, OPPO, @@ -286,190 +224,188 @@ enum SPK_FR }; -typedef struct _HW_EQ_PRESET -{ - u16 HwEqType; - u16 EqValue[22]; - u16 HwEQCtrl; - -}HW_EQ_PRESET; - - -HW_EQ_PRESET HwEq_Preset[]={ -/* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 0x6e*/ - {NORMAL,{0x0000,0x0000,0x0000,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,0x0000,0x0000,0x0000},0x000E}, - {DANCE ,{0x1F2C,0x095B,0xC071,0x1F95,0x0616,0xC96E,0x1B11,0xFC91,0xDCF2,0x1194,0xFAF2,0x0436,0x0000,0x0000,0x0000,0x0000},0x000F}, - {LIVE ,{0x1EB5,0xFCB6,0xC24A,0x1DF8,0x0E7C,0xC883,0x1C10,0x0699,0xDA41,0x1561,0x0295,0x0436,0x0000,0x0000,0x0000,0x0000},0x000F}, - {POP ,{0x1EB5,0xFCB6,0xC1D4,0x1E5D,0x0E23,0xD92E,0x16E6,0xFCB6,0x0000,0x0969,0xF988,0x0436,0x0000,0x0000,0x0000,0x0000},0x000F}, - {ROCK ,{0x1EB5,0xFCB6,0xC071,0x1F95,0x0424,0xC30A,0x1D27,0xF900,0x0C5D,0x0FC7,0x0E23,0x0436,0x0000,0x0000,0x0000,0x0000},0x000F}, - {OPPO ,{0x0000,0x0000,0xCA4A,0x17F8,0x0FEC,0xCA4A,0x17F8,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},0x000F}, - {TREBLE,{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x188D,0x1699,0x0000,0x0000,0x0000},0x0010}, - {BASS ,{0x1A43,0x0C00,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000},0x0001}, - {HFREQ, {0x1BBC,0x0000,0xC9A4,0x1BBC,0x0000,0x2997,0x142D,0xFCB6,0xEF01,0x1BBC,0x0000,0xE835,0x0FEC,0xC66E,0x1A29,0x1CEE},0x0014}, - {SPK_FR,{0x1CD4,0xF405,0xe0bf,0x0f9e,0xfa19,0x07CA,0x12AF,0xF805,0xE904,0x1C10,0x0000,0x1C8B,0x0000,0xc5e1,0x1afb,0x1d46},0x0090}, +struct hw_eq_preset { + u16 type; + u16 value[22]; + u16 ctrl; +}; + +/* + * EQ param reg : 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, + * 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf + * EQ control reg : 0x6e + */ +struct hw_eq_preset hweq_preset[] = { + {NORMAL , {0x0000, 0x0000, 0x0000, 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, 0x0000, 0x0000, 0x0000}, 0x000E}, + {DANCE , {0x1F2C, 0x095B, 0xC071, 0x1F95, 0x0616, 0xC96E, + 0x1B11, 0xFC91, 0xDCF2, 0x1194, 0xFAF2, 0x0436, + 0x0000, 0x0000, 0x0000, 0x0000}, 0x000F}, + {LIVE , {0x1EB5, 0xFCB6, 0xC24A, 0x1DF8, 0x0E7C, 0xC883, + 0x1C10, 0x0699, 0xDA41, 0x1561, 0x0295, 0x0436, + 0x0000, 0x0000, 0x0000, 0x0000}, 0x000F}, + {POP , {0x1EB5, 0xFCB6, 0xC1D4, 0x1E5D, 0x0E23, 0xD92E, + 0x16E6, 0xFCB6, 0x0000, 0x0969, 0xF988, 0x0436, + 0x0000, 0x0000, 0x0000, 0x0000}, 0x000F}, + {ROCK , {0x1EB5, 0xFCB6, 0xC071, 0x1F95, 0x0424, 0xC30A, + 0x1D27, 0xF900, 0x0C5D, 0x0FC7, 0x0E23, 0x0436, + 0x0000, 0x0000, 0x0000, 0x0000}, 0x000F}, + {OPPO , {0x0000, 0x0000, 0xCA4A, 0x17F8, 0x0FEC, 0xCA4A, + 0x17F8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000}, 0x000F}, + {TREBLE , {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x188D, + 0x1699, 0x0000, 0x0000, 0x0000}, 0x0010}, + {BASS , {0x1A43, 0x0C00, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000}, 0x0001}, }; -#endif -//************************************************************************************************* -//************************************************************************************************* static int rt5631_reg_init(struct snd_soc_codec *codec) { int i; - for (i = 0; i < RT5631_INIT_REG_LEN; i ++) { - rt5631_write(codec, init_list[i].reg, init_list[i].val); - } - + for (i = 0; i < RT5631_INIT_REG_LEN; i++) + rt5631_write(codec, init_list[i].reg, init_list[i].val); + return 0; } -static const char *rt5631_spol_source_sel[] = {"SPOLMIX", "MONOIN_RX", "VDAC", "DACL"}; -static const char *rt5631_spor_source_sel[] = {"SPORMIX", "MONOIN_RX", "VDAC", "DACR"}; +static const char *rt5631_spol_source_sel[] = { + "SPOLMIX", "MONOIN_RX", "VDAC", "DACL"}; +static const char *rt5631_spor_source_sel[] = { + "SPORMIX", "MONOIN_RX", "VDAC", "DACR"}; static const char *rt5631_mono_source_sel[] = {"MONOMIX", "MONOIN_RX", "VDAC"}; -static const char *rt5631_input_mode_source_sel[] = {"Single-end", "Differential"}; -static const char *rt5631_mic_boost[] = {"Bypass", "+20db", "+24db", "+30db", +static const char *rt5631_input_mode_source_sel[] = { + "Single-end", "Differential"}; +static const char *rt5631_mic_boost[] = {"Bypass", "+20db", "+24db", "+30db", "+35db", "+40db", "+44db", "+50db", "+52db"}; -#if (RT5631_EQ_FUNC_ENA==1) -static const char *rt5631_eq_sel[] = {"NORMAL", "CLUB","DANCE", "LIVE","POP", - "ROCK", "OPPO", "TREBLE", "BASS"}; -#endif +static const char *rt5631_hpl_source_sel[] = {"LEFT HPVOL", "LEFT DAC"}; +static const char *rt5631_hpr_source_sel[] = {"RIGHT HPVOL", "RIGHT DAC"}; +static const char *rt5631_eq_sel[] = {"NORMAL", "CLUB", "DANCE", "LIVE", "POP", + "ROCK", "OPPO", "TREBLE", "BASS"}; -static const char *rt5631_hpl_source_sel[] = {"LEFT HPVOL","LEFT DAC"}; -static const char *rt5631_hpr_source_sel[] = {"RIGHT HPVOL","RIGHT DAC"}; static const struct soc_enum rt5631_enum[] = { -SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 14, 4, rt5631_spol_source_sel), /*0*/ -SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 10, 4, rt5631_spor_source_sel), /*1*/ -SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 6, 3, rt5631_mono_source_sel), /*2*/ -SOC_ENUM_SINGLE(RT5631_MIC_CTRL_1, 15, 2, rt5631_input_mode_source_sel), /*3*/ -SOC_ENUM_SINGLE(RT5631_MIC_CTRL_1, 7, 2, rt5631_input_mode_source_sel), /*4*/ -SOC_ENUM_SINGLE(RT5631_MONO_INPUT_VOL, 15, 2, rt5631_input_mode_source_sel), /*5*/ -SOC_ENUM_SINGLE(RT5631_MIC_CTRL_2, 12, 9, rt5631_mic_boost), /*6*/ -SOC_ENUM_SINGLE(RT5631_MIC_CTRL_2, 8, 9, rt5631_mic_boost), /*7*/ -SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 3, 2, rt5631_hpl_source_sel), /*8*/ -SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 2, 2, rt5631_hpr_source_sel), /*9*/ -#if (RT5631_EQ_FUNC_ENA==1) -SOC_ENUM_SINGLE(VIRTUAL_POWER_CONTROL, 4, 9, rt5631_eq_sel), /*10*/ -#endif +SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 14, 4, rt5631_spol_source_sel), +SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 10, 4, rt5631_spor_source_sel), +SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 6, 3, rt5631_mono_source_sel), +SOC_ENUM_SINGLE(RT5631_MIC_CTRL_1, 15, 2, rt5631_input_mode_source_sel), +SOC_ENUM_SINGLE(RT5631_MIC_CTRL_1, 7, 2, rt5631_input_mode_source_sel), +SOC_ENUM_SINGLE(RT5631_MONO_INPUT_VOL, 15, 2, rt5631_input_mode_source_sel), +SOC_ENUM_SINGLE(RT5631_MIC_CTRL_2, 12, 9, rt5631_mic_boost), +SOC_ENUM_SINGLE(RT5631_MIC_CTRL_2, 8, 9, rt5631_mic_boost), +SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 3, 2, rt5631_hpl_source_sel), +SOC_ENUM_SINGLE(RT5631_SPK_MONO_HP_OUT_CTRL, 2, 2, rt5631_hpr_source_sel), +SOC_ENUM_SINGLE(0, 4, 9, rt5631_eq_sel), }; -static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - unsigned int val; + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.integer.value[0] = rt5631->dmic_used_flag; - val = rt5631_read(codec, VIRTUAL_POWER_CONTROL) & 0x0004; - val >>= 2; - ucontrol->value.integer.value[0] = val; return 0; } -static void rt5631_close_dmic(struct snd_soc_codec *codec) //disable DMic to ADC filter +static void rt5631_close_dmic(struct snd_soc_codec *codec) { - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, DMIC_L_CH_MUTE | DMIC_R_CH_MUTE, DMIC_L_CH_MUTE_MASK | DMIC_R_CH_MUTE_MASK); - - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, DMIC_DIS, DMIC_ENA_MASK); + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_L_CH_MUTE | DMIC_R_CH_MUTE, + DMIC_L_CH_MUTE_MASK | DMIC_R_CH_MUTE_MASK); + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_DIS, DMIC_ENA_MASK); + return; } -static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - unsigned int old, new; - struct rt5631_priv *rt5631 = codec->private_data; + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); - old = rt5631_read(codec, VIRTUAL_POWER_CONTROL) & 0x0004; - new = ucontrol->value.integer.value[0] << 2; - - if (old == new) + if (rt5631->dmic_used_flag == ucontrol->value.integer.value[0]) return 0; - rt5631_write_mask(codec, VIRTUAL_POWER_CONTROL, new, 0x0004); - - if (new) + if (ucontrol->value.integer.value[0]) { rt5631->dmic_used_flag = 1; - else - { + } else { rt5631_close_dmic(codec); - rt5631->dmic_used_flag=0; + rt5631->dmic_used_flag = 0; } return 0; } +static int rt5631_eq_sel_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); -//************************************************************************************************* -//for EQ function -//************************************************************************************************* -#if (RT5631_EQ_FUNC_ENA==1) + ucontrol->value.integer.value[0] = rt5631->eq_mode; + + return 0; +} static void rt5631_update_eqmode(struct snd_soc_codec *codec, int mode) { - u16 HwEqIndex=0; + int i; - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0x8380, 0x8380); - - if(mode==NORMAL) - { - /*clear EQ parameter*/ - for(HwEqIndex=0;HwEqIndex<=0x0f;HwEqIndex++) - { - rt5631_write_index(codec, HwEqIndex, HwEq_Preset[mode].EqValue[HwEqIndex]); - } - - rt5631_write_mask(codec,0x6e,0x0000,0x003f); //disable Hardware LP,BP1,BP2,BP3,HP1,HP2 block Control - - rt5631_write_index_mask(codec,0x11,0x0000,0x8000); /*disable EQ block*/ + if (NORMAL == mode) { + /* In Normal mode, the EQ parameter is cleared, + * and hardware LP, BP1, BP2, BP3, HP1, HP2 + * block control and EQ block are disabled. + */ + for (i = RT5631_EQ_BW_LOP; i <= RT5631_EQ_HPF_GAIN; i++) + rt5631_write_index(codec, i, + hweq_preset[mode].value[i]); + rt5631_write_mask(codec, RT5631_EQ_CTRL, 0x0000, 0x003f); + rt5631_write_index_mask(codec, RT5631_EQ_PRE_VOL_CTRL + , 0x0000, 0x8000); + } else { + /* Fill and update EQ parameter, + * and EQ block are enabled. + */ + rt5631_write_index_mask(codec, RT5631_EQ_PRE_VOL_CTRL + , 0x8000, 0x8000); + rt5631_write(codec, RT5631_EQ_CTRL, + hweq_preset[mode].ctrl); + for (i = RT5631_EQ_BW_LOP; i <= RT5631_EQ_HPF_GAIN; i++) + rt5631_write_index(codec, i, + hweq_preset[mode].value[i]); + rt5631_write_mask(codec, RT5631_EQ_CTRL, 0x4000, 0x4000); } - else - { - rt5631_write_index_mask(codec,0x11,0x8000,0x8000); /*enable EQ block*/ - - rt5631_write(codec,0x6e,HwEq_Preset[mode].HwEQCtrl); - /*Fill EQ parameter*/ - for(HwEqIndex=0;HwEqIndex<=0x0f;HwEqIndex++) - { - rt5631_write_index(codec, HwEqIndex,HwEq_Preset[mode].EqValue[HwEqIndex]); - } - //update EQ parameter - rt5631_write_mask(codec, 0x6e,0x4000,0x4000); - } + return; } - -static int rt5631_eq_sel_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int rt5631_eq_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; + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); - 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; - } + if (rt5631->eq_mode == ucontrol->value.integer.value[0]) + return 0; - snd_soc_update_bits(codec, e->reg, mask, val); - - DBG( "value=%d\n", ucontrol->value.enumerated.item[0]); rt5631_update_eqmode(codec, ucontrol->value.enumerated.item[0]); + rt5631->eq_mode = ucontrol->value.integer.value[0]; + return 0; } -#endif + #if (RT5631_SPK_TIMER == 1) static void spk_work_handler(struct work_struct *work) { - struct snd_soc_device *socdev = rt5631_socdev; - struct snd_soc_codec *codec = socdev->card->codec; + struct snd_soc_codec *codec = rt5631_codec; bool is_spk = (rt5631_read(codec, 0x4a)) & 0x04; //detect rt5631 reg4a[3], 1'b:SPK, 0'b:HP ; if(last_is_spk != is_spk) printk("%s---%s is in use.last is %s in use\n", __FUNCTION__,is_spk?"speaker":"headphone",last_is_spk?"speaker":"headphone"); @@ -499,62 +435,30 @@ void spk_timer_callback(unsigned long data ) if (ret) printk("Error in mod_timer\n"); } #endif -//************************************************************************************************* -//************************************************************************************************* static const struct snd_kcontrol_new rt5631_snd_controls[] = { -SOC_ENUM("MIC1 Mode Control", rt5631_enum[3]), +SOC_ENUM("MIC1 Mode Control", rt5631_enum[3]), SOC_ENUM("MIC1 Boost", rt5631_enum[6]), - SOC_ENUM("MIC2 Mode Control", rt5631_enum[4]), SOC_ENUM("MIC2 Boost", rt5631_enum[7]), SOC_ENUM("MONOIN Mode Control", rt5631_enum[5]), - SOC_DOUBLE("PCM Playback Volume", RT5631_STEREO_DAC_VOL_2, 8, 0, 255, 1), -SOC_DOUBLE("PCM Playback Switch", RT5631_STEREO_DAC_VOL_1,15, 7, 1, 1), - +SOC_DOUBLE("PCM Playback Switch", RT5631_STEREO_DAC_VOL_1, 15, 7, 1, 1), SOC_DOUBLE("MONOIN_RX Capture Volume", RT5631_MONO_INPUT_VOL, 8, 0, 31, 1), - SOC_DOUBLE("AXI Capture Volume", RT5631_AUX_IN_VOL, 8, 0, 31, 1), - SOC_SINGLE("AXO1 Playback Switch", RT5631_MONO_AXO_1_2_VOL, 15, 1, 1), SOC_SINGLE("AXO2 Playback Switch", RT5631_MONO_AXO_1_2_VOL, 7, 1, 1), SOC_DOUBLE("OUTVOL Playback Volume", RT5631_MONO_AXO_1_2_VOL, 8, 0, 31, 1), - -SOC_DOUBLE("Speaker Playback Switch", RT5631_SPK_OUT_VOL,15, 7, 1, 1), +SOC_DOUBLE("Speaker Playback Switch", RT5631_SPK_OUT_VOL, 15, 7, 1, 1), SOC_DOUBLE("Speaker Playback Volume", RT5631_SPK_OUT_VOL, 8, 0, 63, 1), - SOC_SINGLE("MONO Playback Switch", RT5631_MONO_AXO_1_2_VOL, 13, 1, 1), - -SOC_DOUBLE("HP Playback Switch", RT5631_HP_OUT_VOL,15, 7, 1, 1), +SOC_DOUBLE("HP Playback Switch", RT5631_HP_OUT_VOL, 15, 7, 1, 1), SOC_DOUBLE("HP Playback Volume", RT5631_HP_OUT_VOL, 8, 0, 63, 1), - -//SOC_SINGLE_EXT("HIFI Loopback", ),/*not finished*/ -//SOC_SINGLE_EXT("Voice Loopback", ), /*not finished*/ -SOC_SINGLE_EXT("DMIC Capture Switch", VIRTUAL_POWER_CONTROL, 2, 1, 0, +SOC_SINGLE_EXT("DMIC Capture Switch", 0, 2, 1, 0, rt5631_dmic_get, rt5631_dmic_put), - -#if (RT5631_EQ_FUNC_ENA==1) -SOC_ENUM_EXT("EQ Mode", rt5631_enum[10], snd_soc_get_enum_double, rt5631_eq_sel_put), -#endif +SOC_ENUM_EXT("EQ Mode", rt5631_enum[10], rt5631_eq_sel_get, rt5631_eq_sel_put), }; -static int rt5631_add_controls(struct snd_soc_codec *codec) -{ - int err, i; - - for (i = 0; i < ARRAY_SIZE(rt5631_snd_controls); i ++) { - - err = snd_ctl_add(codec->card, - snd_soc_cnew(&rt5631_snd_controls[i], - codec, NULL)); - if (err < 0) - return err; - } - - return 0; -} - static const struct snd_kcontrol_new rt5631_recmixl_mixer_controls[] = { SOC_DAPM_SINGLE("OUTMIXL Capture Switch", RT5631_ADC_REC_MIXER, 15, 1, 1), SOC_DAPM_SINGLE("MIC1_BST1 Capture Switch", RT5631_ADC_REC_MIXER, 14, 1, 1), @@ -569,12 +473,11 @@ SOC_DAPM_SINGLE("MIC2_BST2 Capture Switch", RT5631_ADC_REC_MIXER, 6, 1, 1), SOC_DAPM_SINGLE("OUTMIXR Capture Switch", RT5631_ADC_REC_MIXER, 7, 1, 1), }; - static const struct snd_kcontrol_new rt5631_spkmixl_mixer_controls[] = { SOC_DAPM_SINGLE("RECMIXL Playback Switch", RT5631_SPK_MIXER_CTRL, 15, 1, 1), -SOC_DAPM_SINGLE("MIC1_P Playback Switch", RT5631_SPK_MIXER_CTRL, 14, 1, 1), +SOC_DAPM_SINGLE("MIC1_P Playback Switch", RT5631_SPK_MIXER_CTRL, 14, 1, 1), SOC_DAPM_SINGLE("DACL Playback Switch", RT5631_SPK_MIXER_CTRL, 13, 1, 1), -SOC_DAPM_SINGLE("OUTMIXL Playback Switch", RT5631_SPK_MIXER_CTRL, 12, 1, 1) +SOC_DAPM_SINGLE("OUTMIXL Playback Switch", RT5631_SPK_MIXER_CTRL, 12, 1, 1), }; static const struct snd_kcontrol_new rt5631_spkmixr_mixer_controls[] = { @@ -593,7 +496,7 @@ SOC_DAPM_SINGLE("MIC2_BST2 Playback Switch", RT5631_OUTMIXER_L_CTRL, 11, 1, 1), SOC_DAPM_SINGLE("MONOIN_RXP Playback Switch", RT5631_OUTMIXER_L_CTRL, 10, 1, 1), SOC_DAPM_SINGLE("AXILVOL Playback Switch", RT5631_OUTMIXER_L_CTRL, 9, 1, 1), SOC_DAPM_SINGLE("AXIRVOL Playback Switch", RT5631_OUTMIXER_L_CTRL, 8, 1, 1), -SOC_DAPM_SINGLE("VDAC Playback Switch", RT5631_OUTMIXER_L_CTRL, 7, 1, 1) +SOC_DAPM_SINGLE("VDAC Playback Switch", RT5631_OUTMIXER_L_CTRL, 7, 1, 1), }; static const struct snd_kcontrol_new rt5631_outmixr_mixer_controls[] = { @@ -602,60 +505,55 @@ SOC_DAPM_SINGLE("AXIRVOL Playback Switch", RT5631_OUTMIXER_R_CTRL, 8, 1, 1), SOC_DAPM_SINGLE("AXILVOL Playback Switch", RT5631_OUTMIXER_R_CTRL, 9, 1, 1), SOC_DAPM_SINGLE("MONOIN_RXN Playback Switch", RT5631_OUTMIXER_R_CTRL, 10, 1, 1), SOC_DAPM_SINGLE("MIC2_BST2 Playback Switch", RT5631_OUTMIXER_R_CTRL, 11, 1, 1), -SOC_DAPM_SINGLE("MIC1_BST1 Playback Switch", RT5631_OUTMIXER_R_CTRL, 12, 1, 1), +SOC_DAPM_SINGLE("MIC1_BST1 Playback Switch", RT5631_OUTMIXER_R_CTRL, 12, 1, 1), SOC_DAPM_SINGLE("DACR Playback Switch", RT5631_OUTMIXER_R_CTRL, 13, 1, 1), SOC_DAPM_SINGLE("RECMIXR Playback Switch", RT5631_OUTMIXER_R_CTRL, 14, 1, 1), SOC_DAPM_SINGLE("RECMIXL Playback Switch", RT5631_OUTMIXER_R_CTRL, 15, 1, 1), }; - static const struct snd_kcontrol_new rt5631_AXO1MIX_mixer_controls[] = { SOC_DAPM_SINGLE("MIC1_BST1 Playback Switch", RT5631_AXO1MIXER_CTRL, 15 , 1, 1), -SOC_DAPM_SINGLE("MIC2_BST2 Playback Switch", RT5631_AXO1MIXER_CTRL, 11, 1, 1), -SOC_DAPM_SINGLE("OUTVOLL Playback Switch", RT5631_AXO1MIXER_CTRL, 7 ,1 ,1), +SOC_DAPM_SINGLE("MIC2_BST2 Playback Switch", RT5631_AXO1MIXER_CTRL, 11, 1, 1), +SOC_DAPM_SINGLE("OUTVOLL Playback Switch", RT5631_AXO1MIXER_CTRL, 7 , 1 , 1), SOC_DAPM_SINGLE("OUTVOLR Playback Switch", RT5631_AXO1MIXER_CTRL, 6, 1, 1), }; - static const struct snd_kcontrol_new rt5631_AXO2MIX_mixer_controls[] = { SOC_DAPM_SINGLE("MIC1_BST1 Playback Switch", RT5631_AXO2MIXER_CTRL, 15, 1, 1), -SOC_DAPM_SINGLE("MIC2_BST2 Playback Switch", RT5631_AXO2MIXER_CTRL, 11, 1, 1), +SOC_DAPM_SINGLE("MIC2_BST2 Playback Switch", RT5631_AXO2MIXER_CTRL, 11, 1, 1), SOC_DAPM_SINGLE("OUTVOLL Playback Switch", RT5631_AXO2MIXER_CTRL, 7, 1, 1), -SOC_DAPM_SINGLE("OUTVOLR Playback Switch", RT5631_AXO2MIXER_CTRL, 6, 1 ,1), +SOC_DAPM_SINGLE("OUTVOLR Playback Switch", RT5631_AXO2MIXER_CTRL, 6, 1 , 1), }; static const struct snd_kcontrol_new rt5631_spolmix_mixer_controls[] = { SOC_DAPM_SINGLE("SPKVOLL Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 15, 1, 1), -SOC_DAPM_SINGLE("SPKVOLR Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 14, 1, 1), +SOC_DAPM_SINGLE("SPKVOLR Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 14, 1, 1), }; - static const struct snd_kcontrol_new rt5631_spormix_mixer_controls[] = { SOC_DAPM_SINGLE("SPKVOLL Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 13, 1, 1), SOC_DAPM_SINGLE("SPKVOLR Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 12, 1, 1), }; - static const struct snd_kcontrol_new rt5631_monomix_mixer_controls[] = { SOC_DAPM_SINGLE("OUTVOLL Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 11, 1, 1), SOC_DAPM_SINGLE("OUTVOLR Playback Switch", RT5631_SPK_MONO_OUT_CTRL, 10, 1, 1), }; - -static const struct snd_kcontrol_new rt5631_spol_mux_control = +static const struct snd_kcontrol_new rt5631_spol_mux_control = SOC_DAPM_ENUM("Route", rt5631_enum[0]); -static const struct snd_kcontrol_new rt5631_spor_mux_control = +static const struct snd_kcontrol_new rt5631_spor_mux_control = SOC_DAPM_ENUM("Route", rt5631_enum[1]); -static const struct snd_kcontrol_new rt5631_mono_mux_control = +static const struct snd_kcontrol_new rt5631_mono_mux_control = SOC_DAPM_ENUM("Route", rt5631_enum[2]); -static const struct snd_kcontrol_new rt5631_hpl_mux_control = +static const struct snd_kcontrol_new rt5631_hpl_mux_control = SOC_DAPM_ENUM("Route", rt5631_enum[8]); -static const struct snd_kcontrol_new rt5631_hpr_mux_control = +static const struct snd_kcontrol_new rt5631_hpr_mux_control = SOC_DAPM_ENUM("Route", rt5631_enum[9]); //ALC for DAC function -#if (RT5631_ALC_DAC_FUNC_ENA==1) +#if (RT5631_ALC_DAC_FUNC_ENA == 1) static void rt5631_alc_enable(struct snd_soc_codec *codec,unsigned int EnableALC) { if(EnableALC) @@ -677,280 +575,520 @@ static void rt5631_alc_enable(struct snd_soc_codec *codec,unsigned int EnableALC } #endif -static int spk_event(struct snd_soc_dapm_widget *w, + +static int spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - unsigned int l, r; - - l = rt5631_read(codec, VIRTUAL_POWER_CONTROL) & 0x0001; - r = (rt5631_read(codec, VIRTUAL_POWER_CONTROL) & 0x0002) >> 1; - - switch (event) { - case SND_SOC_DAPM_POST_PMD: - DBG("spk_event --SND_SOC_DAPM_POST_PMD\n"); - rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, 0x8080, 0x8080); + static int spkl_out_enable, spkr_out_enable; - if ((l == 0) && (r == 0)) - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0x0000, 0x1000); - - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD4, 0x0000, 0xC000); -#if (RT5631_ALC_DAC_FUNC_ENA==1) - rt5631_alc_enable(codec,0); -#endif - - break; + switch (event) { case SND_SOC_DAPM_POST_PMU: - DBG("spk_event --SND_SOC_DAPM_POST_PMU \n"); -#if (RT5631_ALC_DAC_FUNC_ENA==1) - rt5631_alc_enable(codec,1); + +#if (RT5631_ALC_DAC_FUNC_ENA == 1) + rt5631_alc_enable(codec, 1); #endif - if ((l != 0) || (r != 0)) - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0x1000, 0x1000); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD4, 0xC000, 0xC000); - rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, 0x0000, 0x8080); + + if (!spkl_out_enable && !strcmp(w->name, "SPKL Amp")) { + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD4, + PWR_SPK_L_VOL, PWR_SPK_L_VOL); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, + PWR_CLASS_D, PWR_CLASS_D); + rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, + 0, RT_L_MUTE); + spkl_out_enable = 1; + } + if (!spkr_out_enable && !strcmp(w->name, "SPKR Amp")) { + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD4, + PWR_SPK_R_VOL, PWR_SPK_R_VOL); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, + PWR_CLASS_D, PWR_CLASS_D); + rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, + 0, RT_R_MUTE); + spkr_out_enable = 1; + } break; + + case SND_SOC_DAPM_POST_PMD: + if (spkl_out_enable && !strcmp(w->name, "SPKL Amp")) { + rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, + RT_L_MUTE, RT_L_MUTE); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD4, + 0, PWR_SPK_L_VOL); + spkl_out_enable = 0; + } + if (spkr_out_enable && !strcmp(w->name, "SPKR Amp")) { + rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, + RT_R_MUTE, RT_R_MUTE); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD4, + 0, PWR_SPK_R_VOL); + spkr_out_enable = 0; + } + if (0 == spkl_out_enable && 0 == spkr_out_enable) + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, + 0, PWR_CLASS_D); + +#if (RT5631_ALC_DAC_FUNC_ENA == 1) + rt5631_alc_enable(codec, 0); +#endif + + break; + default: - return -EINVAL; + return 0; } - + return 0; } -static void hp_depop2(struct snd_soc_codec *codec,unsigned int EnableHPOut) -{ +static void hp_depop_mode2_onebit(struct snd_soc_codec *codec, int enable) +{ + unsigned int soft_vol, hp_zc; - unsigned int SoftVol,HPZeroCross; + rt5631_write_mask(codec, RT5631_DEPOP_FUN_CTRL_2, 0, EN_ONE_BIT_DEPOP); - SoftVol = rt5631_read(codec, RT5631_SOFT_VOL_CTRL); - rt5631_write(codec,RT5631_SOFT_VOL_CTRL,0); - HPZeroCross=rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2); - rt5631_write(codec,RT5631_INT_ST_IRQ_CTRL_2,HPZeroCross&0xf7ff); //disable Zero Cross of HP - //enable HP out - if(EnableHPOut) - { - - rt5631_write_index(codec,0x56,0x303e); - - rt5631_write_mask(codec,RT5631_PWR_MANAG_ADD3,PWR_CHARGE_PUMP|PWR_HP_L_AMP|PWR_HP_R_AMP - ,PWR_CHARGE_PUMP|PWR_HP_L_AMP|PWR_HP_R_AMP); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN|EN_DEPOP2_FOR_HP); - schedule_timeout_uninterruptible(msecs_to_jiffies(100)); - rt5631_write_mask(codec,RT5631_PWR_MANAG_ADD3,PWR_HP_DEPOP_DIS/*|PWR_HP_AMP_DRIVING*/,PWR_HP_DEPOP_DIS/*|PWR_HP_AMP_DRIVING*/); + soft_vol = rt5631_read(codec, RT5631_SOFT_VOL_CTRL); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + if (enable) { + rt5631_write_index(codec, RT5631_TEST_MODE_CTRL, 0x84c0); + rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x309f); + rt5631_write_index(codec, RT5631_CP_INTL_REG2, 0x6530); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_2, + EN_CAP_FREE_DEPOP); + } else { + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_2, 0); + schedule_timeout_uninterruptible(msecs_to_jiffies(100)); } - else //disable HP out - { - rt5631_write_index(codec,0x56,0x303F); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN|EN_MUTE_UNMUTE_DEPOP|PD_HPAMP_L_ST_UP|PD_HPAMP_R_ST_UP); - schedule_timeout_uninterruptible(msecs_to_jiffies(75)); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN|PD_HPAMP_L_ST_UP|PD_HPAMP_R_ST_UP); - rt5631_write_mask(codec,RT5631_PWR_MANAG_ADD3,0,PWR_HP_DEPOP_DIS/*|PWR_HP_AMP_DRIVING*/); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN|EN_DEPOP2_FOR_HP|PD_HPAMP_L_ST_UP|PD_HPAMP_R_ST_UP); - schedule_timeout_uninterruptible(msecs_to_jiffies(80)); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN); - rt5631_write_mask(codec,RT5631_PWR_MANAG_ADD3,0,PWR_CHARGE_PUMP|PWR_HP_L_AMP|PWR_HP_R_AMP); - } - - rt5631_write(codec,RT5631_SOFT_VOL_CTRL,SoftVol); - rt5631_write(codec,RT5631_INT_ST_IRQ_CTRL_2,HPZeroCross); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + + return; } -static void HP_Mute_Unmute_Depop(struct snd_soc_codec *codec,unsigned int EnableHPOut) +static void hp_mute_unmute_depop_onebit(struct snd_soc_codec *codec, int enable) { + unsigned int soft_vol, hp_zc; - unsigned int SoftVol,HPZeroCross; - - DBG("%s: %d\n", __func__, EnableHPOut); - - SoftVol = rt5631_read(codec, RT5631_SOFT_VOL_CTRL); - rt5631_write(codec,RT5631_SOFT_VOL_CTRL,0); - HPZeroCross=rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2); - rt5631_write(codec,RT5631_INT_ST_IRQ_CTRL_2,HPZeroCross&0xf7ff); //disable Zero Cross of HP - - if(EnableHPOut) //unmute HP out - { + rt5631_write_mask(codec, RT5631_DEPOP_FUN_CTRL_2, 0, EN_ONE_BIT_DEPOP); + soft_vol = rt5631_read(codec, RT5631_SOFT_VOL_CTRL); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + if (enable) { schedule_timeout_uninterruptible(msecs_to_jiffies(10)); - rt5631_write_index(codec,0x56,0x302f); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN|EN_MUTE_UNMUTE_DEPOP|EN_HP_R_M_UN_MUTE_DEPOP|EN_HP_L_M_UN_MUTE_DEPOP); - rt5631_write_mask(codec,RT5631_HP_OUT_VOL,0x0000,0x8080); - schedule_timeout_uninterruptible(msecs_to_jiffies(160)); - + rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x307f); + rt5631_write_mask(codec, RT5631_HP_OUT_VOL, 0, + RT_L_MUTE | RT_R_MUTE); + schedule_timeout_uninterruptible(msecs_to_jiffies(300)); + + } else { + rt5631_write_mask(codec, RT5631_HP_OUT_VOL, + RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE); + schedule_timeout_uninterruptible(msecs_to_jiffies(100)); } - else //mute HP out - { - rt5631_write_index(codec,0x56,0x302f); - rt5631_write(codec,RT5631_DEPOP_FUN_CTRL_1,POW_ON_SOFT_GEN|EN_MUTE_UNMUTE_DEPOP|EN_HP_R_M_UN_MUTE_DEPOP|EN_HP_L_M_UN_MUTE_DEPOP); - rt5631_write_mask(codec,RT5631_HP_OUT_VOL,0x8080,0x8080); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + + return; +} + +static void hp_depop2(struct snd_soc_codec *codec, int enable) +{ + unsigned int soft_vol, hp_zc; + + rt5631_write_mask(codec, RT5631_DEPOP_FUN_CTRL_2, + EN_ONE_BIT_DEPOP, EN_ONE_BIT_DEPOP); + soft_vol = rt5631_read(codec, RT5631_SOFT_VOL_CTRL); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + if (enable) { + rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x303e); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_CHARGE_PUMP | PWR_HP_L_AMP | PWR_HP_R_AMP, + PWR_CHARGE_PUMP | PWR_HP_L_AMP | PWR_HP_R_AMP); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, + POW_ON_SOFT_GEN | EN_DEPOP2_FOR_HP); + schedule_timeout_uninterruptible(msecs_to_jiffies(100)); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_HP_DEPOP_DIS, PWR_HP_DEPOP_DIS); + } else { + rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x303F); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, + POW_ON_SOFT_GEN | EN_MUTE_UNMUTE_DEPOP | + PD_HPAMP_L_ST_UP | PD_HPAMP_R_ST_UP); + schedule_timeout_uninterruptible(msecs_to_jiffies(75)); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, + POW_ON_SOFT_GEN | PD_HPAMP_L_ST_UP | PD_HPAMP_R_ST_UP); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, 0, + PWR_HP_DEPOP_DIS); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, + POW_ON_SOFT_GEN | EN_DEPOP2_FOR_HP | + PD_HPAMP_L_ST_UP | PD_HPAMP_R_ST_UP); + schedule_timeout_uninterruptible(msecs_to_jiffies(80)); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, POW_ON_SOFT_GEN); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, 0, + PWR_CHARGE_PUMP | PWR_HP_L_AMP | PWR_HP_R_AMP); + } + + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + + return; +} + +static void hp_mute_unmute_depop(struct snd_soc_codec *codec, int enable) +{ + unsigned int soft_vol, hp_zc; + + rt5631_write_mask(codec, RT5631_DEPOP_FUN_CTRL_2, + EN_ONE_BIT_DEPOP, EN_ONE_BIT_DEPOP); + soft_vol = rt5631_read(codec, RT5631_SOFT_VOL_CTRL); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + if (enable) { + schedule_timeout_uninterruptible(msecs_to_jiffies(10)); + rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x302f); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, + POW_ON_SOFT_GEN | EN_MUTE_UNMUTE_DEPOP | + EN_HP_R_M_UN_MUTE_DEPOP | EN_HP_L_M_UN_MUTE_DEPOP); + rt5631_write_mask(codec, RT5631_HP_OUT_VOL, 0, + RT_L_MUTE | RT_R_MUTE); + schedule_timeout_uninterruptible(msecs_to_jiffies(160)); + } else { + rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x302f); + rt5631_write(codec, RT5631_DEPOP_FUN_CTRL_1, + POW_ON_SOFT_GEN | EN_MUTE_UNMUTE_DEPOP | + EN_HP_R_M_UN_MUTE_DEPOP | EN_HP_L_M_UN_MUTE_DEPOP); + rt5631_write_mask(codec, RT5631_HP_OUT_VOL, + RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE); schedule_timeout_uninterruptible(msecs_to_jiffies(150)); } - - rt5631_write(codec,RT5631_SOFT_VOL_CTRL,SoftVol); - rt5631_write(codec,RT5631_INT_ST_IRQ_CTRL_2,HPZeroCross); + rt5631_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); + rt5631_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + + return; } -static int open_hp_end_widgets(struct snd_soc_codec *codec) -{ - /*need to be fixed*/ - /* - * - *open hp last widget, e.g. power, switch - */ - - HP_Mute_Unmute_Depop(codec,1); - - return 0; -} - -static int close_hp_end_widgets(struct snd_soc_codec *codec) -{ - /*need to be fixed*/ - /* - * - *close hp last widget, e.g. power, switch - */ - - HP_Mute_Unmute_Depop(codec,0); - - return 0; -} -static int hp_event(struct snd_soc_dapm_widget *w, +static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - unsigned int l, r; - static unsigned int hp_out_enable=0; - - l = (rt5631_read(codec, RT5631_PWR_MANAG_ADD4) & (0x01 << 11)) >> 11; - r = (rt5631_read(codec, RT5631_PWR_MANAG_ADD4) & (0x01 << 10)) >> 10; - + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + static bool hp_en; + int pu_l, pu_r; + + pu_l = rt5631_read(codec, RT5631_PWR_MANAG_ADD4) & PWR_HP_L_OUT_VOL; + pu_r = rt5631_read(codec, RT5631_PWR_MANAG_ADD4) & PWR_HP_R_OUT_VOL; switch (event) { case SND_SOC_DAPM_PRE_PMD: - DBG("hp_event --SND_SOC_DAPM_PRE_PMD\n"); - if ((l && r)&&(hp_out_enable)) - { - close_hp_end_widgets(codec); - hp_depop2(codec,0); - hp_out_enable=0; + if ((pu_l && pu_r) && hp_en) { + if (rt5631->codec_version) { + hp_mute_unmute_depop_onebit(codec, 0); + hp_depop_mode2_onebit(codec, 0); + } else { + hp_mute_unmute_depop(codec, 0); + hp_depop2(codec, 0); + } + hp_en = false; } break; + case SND_SOC_DAPM_POST_PMU: - DBG("hp_event --SND_SOC_DAPM_POST_PMU\n"); - if ((l && r)&&(!hp_out_enable)) - { - hp_depop2(codec,1); - open_hp_end_widgets(codec); - hp_out_enable=1; + if ((pu_l && pu_r) && !hp_en) { + if (rt5631->codec_version) { + hp_depop_mode2_onebit(codec, 1); + hp_mute_unmute_depop_onebit(codec, 1); + } else { + hp_depop2(codec, 1); + hp_mute_unmute_depop(codec, 1); + } + hp_en = true; } break; + default: - return 0; + break; } - + return 0; } -static int dac_to_hp_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) +static int dac_to_hp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - unsigned int l, r; - static unsigned int hp_out_enable=0; - - l = (rt5631_read(codec, VIRTUAL_POWER_CONTROL) & (0x01 << 8)) >> 8; - r = (rt5631_read(codec, VIRTUAL_POWER_CONTROL) & (0x01 << 9)) >> 9; - + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + static bool hp_en; + switch (event) { case SND_SOC_DAPM_PRE_PMD: - DBG("dac_to_hp_event --SND_SOC_DAPM_PRE_PMD l=%x,r=%x,hp_out_enable=%x\n",l,r,hp_out_enable); - if ((l && r)&&(hp_out_enable)) - { + if (hp_en) { + if (rt5631->codec_version) { + hp_mute_unmute_depop_onebit(codec, 0); + hp_depop_mode2_onebit(codec, 0); + } else { + hp_mute_unmute_depop(codec, 0); + hp_depop2(codec, 0); + } + hp_en = false; + } + break; - HP_Mute_Unmute_Depop(codec,0); - hp_depop2(codec,0); - hp_out_enable=0; - } - break; case SND_SOC_DAPM_POST_PMU: - DBG("dac_to_hp_event --SND_SOC_DAPM_POST_PMUl=%x,r=%x,hp_out_enable=%x\n",l,r,hp_out_enable); - if ((l && r)&&(!hp_out_enable)) - { - hp_depop2(codec,1); - HP_Mute_Unmute_Depop(codec,1); - hp_out_enable=1; + if (!hp_en) { + if (rt5631->codec_version) { + hp_depop_mode2_onebit(codec, 1); + hp_mute_unmute_depop_onebit(codec, 1); + } else { + hp_depop2(codec, 1); + hp_mute_unmute_depop(codec, 1); + } + hp_en = true; } break; + default: - return 0; + break; } - + return 0; } - -static int mic_event(struct snd_soc_dapm_widget *w, +static int mic_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = w->codec; - unsigned int mic1_gain_power,mic2_gain_power; - - mic1_gain_power = (rt5631_read(codec, RT5631_PWR_MANAG_ADD2) & 0x0020) >>5; - mic2_gain_power = (rt5631_read(codec, RT5631_PWR_MANAG_ADD2) & 0x0010) >>4; - + int val_mic1, val_mic2; + + val_mic1 = rt5631_read(codec, RT5631_PWR_MANAG_ADD2) & + PWR_MIC1_BOOT_GAIN; + val_mic2 = rt5631_read(codec, RT5631_PWR_MANAG_ADD2) & + PWR_MIC2_BOOT_GAIN; + switch (event) { + case SND_SOC_DAPM_POST_PMU: + /* + * If microphone is stereo, need not copy ADC channel + * If mic1 is used, copy ADC left to right + * If mic2 is used, copy ADC right to left + */ + if (val_mic1 && val_mic2) + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0x0000, 0xc000); + else if (val_mic1) + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0x4000, 0xc000); + else if (val_mic2) + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0x8000, 0xc000); + else + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0x0000, 0xc000); + break; + + default: + break; + } + + return 0; +} + +static int auxo1_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = w->codec; + static bool aux1_en; + + switch (event) { + case SND_SOC_DAPM_PRE_PMD: + if (aux1_en) { + rt5631_write_mask(codec, RT5631_MONO_AXO_1_2_VOL, + RT_L_MUTE, RT_L_MUTE); + aux1_en = false; + } + break; + + case SND_SOC_DAPM_POST_PMU: + if (!aux1_en) { + rt5631_write_mask(codec, RT5631_MONO_AXO_1_2_VOL, + 0, RT_L_MUTE); + aux1_en = true; + } + break; + + default: + break; + } + + return 0; +} + +static int auxo2_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = w->codec; + static bool aux2_en; + + switch (event) { + case SND_SOC_DAPM_PRE_PMD: + if (aux2_en) { + rt5631_write_mask(codec, RT5631_MONO_AXO_1_2_VOL, + RT_R_MUTE, RT_R_MUTE); + aux2_en = false; + } + break; + + case SND_SOC_DAPM_POST_PMU: + if (!aux2_en) { + rt5631_write_mask(codec, RT5631_MONO_AXO_1_2_VOL, + 0, RT_R_MUTE); + aux2_en = true; + } + break; + + default: + break; + } + + return 0; +} + +static int mono_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = w->codec; + static bool mono_en; + + switch (event) { + case SND_SOC_DAPM_PRE_PMD: + if (mono_en) { + rt5631_write_mask(codec, RT5631_MONO_AXO_1_2_VOL, + MUTE_MONO, MUTE_MONO); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + 0, PWR_MONO_DEPOP_DIS); + mono_en = false; + } + break; + + case SND_SOC_DAPM_POST_PMU: + if (!mono_en) { + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_MONO_DEPOP_DIS, PWR_MONO_DEPOP_DIS); + rt5631_write_mask(codec, RT5631_MONO_AXO_1_2_VOL, + 0, MUTE_MONO); + mono_en = true; + } + break; + + default: + break; + } + + return 0; +} + +/** + * config_common_power - control all common power of codec system + * @pmu: power up or not + */ +static int config_common_power(struct snd_soc_codec *codec, bool pmu) +{ + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + unsigned int mux_val; + + if (pmu) { + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, + PWR_MAIN_I2S_EN | PWR_DAC_REF, + PWR_MAIN_I2S_EN | PWR_DAC_REF); + mux_val = rt5631_read(codec, RT5631_SPK_MONO_HP_OUT_CTRL); + //if (!(mux_val & HP_L_MUX_SEL_DAC_L)) + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, + PWR_DAC_L_TO_MIXER, PWR_DAC_L_TO_MIXER); + //if (!(mux_val & HP_R_MUX_SEL_DAC_R)) + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, + PWR_DAC_R_TO_MIXER, PWR_DAC_R_TO_MIXER); + if (rt5631->pll_used_flag) + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, + PWR_PLL, PWR_PLL); + } else if (isPlaybackon == false && isCaptureon == false){ + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0, + PWR_MAIN_I2S_EN | PWR_DAC_REF | + PWR_DAC_L_TO_MIXER | PWR_DAC_R_TO_MIXER); + if (rt5631->pll_used_flag) + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, + 0, PWR_PLL); + } + + return 0; +} + +static int adc_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = w->codec; + static bool pmu; + switch (event) { case SND_SOC_DAPM_POST_PMD: - DBG("mic_event --SND_SOC_DAPM_POST_PMD\n"); - - if(mic1_gain_power&&mic2_gain_power) //use stereo mic from mic1&mic2,no copy ADC channel - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0000, 0xc000); - } - else if(mic1_gain_power) //use mic1,copy ADC left to right - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x4000, 0xc000); - } - else if(mic2_gain_power)//use mic2,copy ADC right to left - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x8000, 0xc000); - } - else - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0000, 0xc000); - } + if (pmu) { + isPlaybackon = false; + config_common_power(codec, false); + pmu = false; + } + break; + case SND_SOC_DAPM_PRE_PMU: + if (!pmu) { + isPlaybackon = true; + config_common_power(codec, true); + pmu = true; + } break; - case SND_SOC_DAPM_POST_PMU: - DBG("mic_event --SND_SOC_DAPM_POST_PMU\n"); - - if(mic1_gain_power&&mic2_gain_power) //use stereo mic from mic1&mic2,no copy ADC channel - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0000, 0xc000); - } - else if(mic1_gain_power) //use mic1,copy ADC left to right - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x4000, 0xc000); - } - else if(mic2_gain_power)//use mic2,copy ADC right to left - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x8000, 0xc000); - } - else - { - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0000, 0xc000); - } - - break; + default: + break; + } + return 0; } +static int dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = w->codec; + static bool pmu; + + switch (event) { + case SND_SOC_DAPM_POST_PMD: + if (pmu) { + isCaptureon = false; + config_common_power(codec, false); + pmu = false; + } + break; + + case SND_SOC_DAPM_PRE_PMU: + if (!pmu) { + isCaptureon = true; + config_common_power(codec, true); + pmu = true; + } + break; + + default: + break; + } + return 0; } static const struct snd_soc_dapm_widget rt5631_dapm_widgets[] = { - SND_SOC_DAPM_INPUT("MIC1"), SND_SOC_DAPM_INPUT("MIC2"), SND_SOC_DAPM_INPUT("AXIL"), @@ -958,42 +1096,55 @@ SND_SOC_DAPM_INPUT("AXIR"), SND_SOC_DAPM_INPUT("MONOIN_RXN"), SND_SOC_DAPM_INPUT("MONOIN_RXP"), +SND_SOC_DAPM_MICBIAS("Mic Bias1", RT5631_PWR_MANAG_ADD2, 3, 0), +SND_SOC_DAPM_MICBIAS("Mic Bias2", RT5631_PWR_MANAG_ADD2, 2, 0), + SND_SOC_DAPM_PGA_E("Mic1 Boost", RT5631_PWR_MANAG_ADD2, 5, 0, NULL, 0, - mic_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), - + mic_event, SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_E("Mic2 Boost", RT5631_PWR_MANAG_ADD2, 4, 0, NULL, 0, - mic_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), - - -SND_SOC_DAPM_PGA("MONOIN_RXP Boost", RT5631_PWR_MANAG_ADD4, 7, 0, NULL, 0), -SND_SOC_DAPM_PGA("MONOIN_RXN Boost", RT5631_PWR_MANAG_ADD4, 6, 0, NULL, 0), - -SND_SOC_DAPM_PGA("AXIL Boost", RT5631_PWR_MANAG_ADD4, 9, 0, NULL, 0), + mic_event, SND_SOC_DAPM_POST_PMU), +SND_SOC_DAPM_PGA("MONOIN_RXP Boost", RT5631_PWR_MANAG_ADD4, 7, 0, NULL, 0), +SND_SOC_DAPM_PGA("MONOIN_RXN Boost", RT5631_PWR_MANAG_ADD4, 6, 0, NULL, 0), +SND_SOC_DAPM_PGA("AXIL Boost", RT5631_PWR_MANAG_ADD4, 9, 0, NULL, 0), SND_SOC_DAPM_PGA("AXIR Boost", RT5631_PWR_MANAG_ADD4, 8, 0, NULL, 0), SND_SOC_DAPM_MIXER("MONO_IN", SND_SOC_NOPM, 0, 0, NULL, 0), -SND_SOC_DAPM_MIXER("RECMIXL Mixer", RT5631_PWR_MANAG_ADD2, 11, 0, - &rt5631_recmixl_mixer_controls[0], ARRAY_SIZE(rt5631_recmixl_mixer_controls)), -SND_SOC_DAPM_MIXER("RECMIXR Mixer", RT5631_PWR_MANAG_ADD2, 10, 0, - &rt5631_recmixr_mixer_controls[0], ARRAY_SIZE(rt5631_recmixr_mixer_controls)), - +SND_SOC_DAPM_MIXER("RECMIXL Mixer", RT5631_PWR_MANAG_ADD2, 11, 0, + &rt5631_recmixl_mixer_controls[0], + ARRAY_SIZE(rt5631_recmixl_mixer_controls)), +SND_SOC_DAPM_MIXER("RECMIXR Mixer", RT5631_PWR_MANAG_ADD2, 10, 0, + &rt5631_recmixr_mixer_controls[0], + ARRAY_SIZE(rt5631_recmixr_mixer_controls)), SND_SOC_DAPM_MIXER("ADC Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), -SND_SOC_DAPM_ADC("Left ADC", "Left ADC HIFI Capture", RT5631_PWR_MANAG_ADD1, 11, 0), -SND_SOC_DAPM_ADC("Right ADC", "Right ADC HIFI Capture", RT5631_PWR_MANAG_ADD1, 10, 0), -SND_SOC_DAPM_DAC("Left DAC", "Left DAC HIFI Playback", RT5631_PWR_MANAG_ADD1, 9, 0), -SND_SOC_DAPM_DAC("Right DAC", "Right DAC HIFI Playback", RT5631_PWR_MANAG_ADD1, 8, 0), +SND_SOC_DAPM_ADC_E("Left ADC", "Left ADC HIFI Capture", + RT5631_PWR_MANAG_ADD1, 11, 0, + adc_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_ADC_E("Right ADC", "Right ADC HIFI Capture", + RT5631_PWR_MANAG_ADD1, 10, 0, + adc_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_DAC_E("Left DAC", "Left DAC HIFI Playback", + RT5631_PWR_MANAG_ADD1, 9, 0, + dac_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU), +SND_SOC_DAPM_DAC_E("Right DAC", "Right DAC HIFI Playback", + RT5631_PWR_MANAG_ADD1, 8, 0, + dac_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_DAC("Voice DAC", "Voice DAC Mono Playback", SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_PGA("Voice DAC Boost", SND_SOC_NOPM, 0, 0, NULL, 0), -SND_SOC_DAPM_MIXER("SPKMIXL Mixer", RT5631_PWR_MANAG_ADD2, 13, 0, - &rt5631_spkmixl_mixer_controls[0], ARRAY_SIZE(rt5631_spkmixl_mixer_controls)), -SND_SOC_DAPM_MIXER("OUTMIXL Mixer", RT5631_PWR_MANAG_ADD2, 15, 0, - &rt5631_outmixl_mixer_controls[0], ARRAY_SIZE(rt5631_outmixl_mixer_controls)), -SND_SOC_DAPM_MIXER("OUTMIXR Mixer", RT5631_PWR_MANAG_ADD2, 14, 0, - &rt5631_outmixr_mixer_controls[0], ARRAY_SIZE(rt5631_outmixr_mixer_controls)), -SND_SOC_DAPM_MIXER("SPKMIXR Mixer", RT5631_PWR_MANAG_ADD2, 12, 0, - &rt5631_spkmixr_mixer_controls[0], ARRAY_SIZE(rt5631_spkmixr_mixer_controls)), +SND_SOC_DAPM_MIXER("SPKMIXL Mixer", RT5631_PWR_MANAG_ADD2, 13, 0, + &rt5631_spkmixl_mixer_controls[0], + ARRAY_SIZE(rt5631_spkmixl_mixer_controls)), +SND_SOC_DAPM_MIXER("OUTMIXL Mixer", RT5631_PWR_MANAG_ADD2, 15, 0, + &rt5631_outmixl_mixer_controls[0], + ARRAY_SIZE(rt5631_outmixl_mixer_controls)), +SND_SOC_DAPM_MIXER("OUTMIXR Mixer", RT5631_PWR_MANAG_ADD2, 14, 0, + &rt5631_outmixr_mixer_controls[0], + ARRAY_SIZE(rt5631_outmixr_mixer_controls)), +SND_SOC_DAPM_MIXER("SPKMIXR Mixer", RT5631_PWR_MANAG_ADD2, 12, 0, + &rt5631_spkmixr_mixer_controls[0], + ARRAY_SIZE(rt5631_spkmixr_mixer_controls)), + SND_SOC_DAPM_PGA("Left SPK Vol", RT5631_PWR_MANAG_ADD4, 15, 0, NULL, 0), SND_SOC_DAPM_PGA("Right SPK Vol", RT5631_PWR_MANAG_ADD4, 14, 0, NULL, 0), SND_SOC_DAPM_PGA_E("Left HP Vol", RT5631_PWR_MANAG_ADD4, 11, 0, NULL, 0, @@ -1001,57 +1152,56 @@ SND_SOC_DAPM_PGA_E("Left HP Vol", RT5631_PWR_MANAG_ADD4, 11, 0, NULL, 0, SND_SOC_DAPM_PGA_E("Right HP Vol", RT5631_PWR_MANAG_ADD4, 10, 0, NULL, 0, hp_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), -SND_SOC_DAPM_PGA_E("Left DAC_HP", VIRTUAL_POWER_CONTROL, 8, 0, NULL, 0, - dac_to_hp_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), -SND_SOC_DAPM_PGA_E("Right DAC_HP", VIRTUAL_POWER_CONTROL,9, 0, NULL, 0, - dac_to_hp_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), +SND_SOC_DAPM_PGA_E("Left DAC_HP", SND_SOC_NOPM, 0, 0, NULL, 0, + dac_to_hp_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), +SND_SOC_DAPM_PGA_E("Right DAC_HP", SND_SOC_NOPM, 0, 0, NULL, 0, + dac_to_hp_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA("Left Out Vol", RT5631_PWR_MANAG_ADD4, 13, 0, NULL, 0), SND_SOC_DAPM_PGA("Right Out Vol", RT5631_PWR_MANAG_ADD4, 12, 0, NULL, 0), -SND_SOC_DAPM_MIXER("AXO1MIX Mixer", RT5631_PWR_MANAG_ADD3, 11, 0, - &rt5631_AXO1MIX_mixer_controls[0], ARRAY_SIZE(rt5631_AXO1MIX_mixer_controls)), -SND_SOC_DAPM_MIXER("SPOLMIX Mixer", SND_SOC_NOPM, 0, 0, - &rt5631_spolmix_mixer_controls[0], ARRAY_SIZE(rt5631_spolmix_mixer_controls)), -SND_SOC_DAPM_MIXER("MONOMIX Mixer", RT5631_PWR_MANAG_ADD3, 9, 0, - &rt5631_monomix_mixer_controls[0], ARRAY_SIZE(rt5631_monomix_mixer_controls)), -SND_SOC_DAPM_MIXER("SPORMIX Mixer", SND_SOC_NOPM, 0, 0, - &rt5631_spormix_mixer_controls[0], ARRAY_SIZE(rt5631_spormix_mixer_controls)), -SND_SOC_DAPM_MIXER("AXO2MIX Mixer", RT5631_PWR_MANAG_ADD3, 10, 0, - &rt5631_AXO2MIX_mixer_controls[0], ARRAY_SIZE(rt5631_AXO2MIX_mixer_controls)), - +SND_SOC_DAPM_MIXER_E("AXO1MIX Mixer", RT5631_PWR_MANAG_ADD3, 11, 0, + &rt5631_AXO1MIX_mixer_controls[0], + ARRAY_SIZE(rt5631_AXO1MIX_mixer_controls), + auxo1_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), +SND_SOC_DAPM_MIXER("SPOLMIX Mixer", SND_SOC_NOPM, 0, 0, + &rt5631_spolmix_mixer_controls[0], + ARRAY_SIZE(rt5631_spolmix_mixer_controls)), +SND_SOC_DAPM_MIXER("MONOMIX Mixer", RT5631_PWR_MANAG_ADD3, 9, 0, + &rt5631_monomix_mixer_controls[0], + ARRAY_SIZE(rt5631_monomix_mixer_controls)), +SND_SOC_DAPM_MIXER("SPORMIX Mixer", SND_SOC_NOPM, 0, 0, + &rt5631_spormix_mixer_controls[0], + ARRAY_SIZE(rt5631_spormix_mixer_controls)), +SND_SOC_DAPM_MIXER_E("AXO2MIX Mixer", RT5631_PWR_MANAG_ADD3, 10, 0, + &rt5631_AXO2MIX_mixer_controls[0], + ARRAY_SIZE(rt5631_AXO2MIX_mixer_controls), + auxo2_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_MUX("SPOL Mux", SND_SOC_NOPM, 0, 0, &rt5631_spol_mux_control), SND_SOC_DAPM_MUX("SPOR Mux", SND_SOC_NOPM, 0, 0, &rt5631_spor_mux_control), SND_SOC_DAPM_MUX("Mono Mux", SND_SOC_NOPM, 0, 0, &rt5631_mono_mux_control), - SND_SOC_DAPM_MUX("HPL Mux", SND_SOC_NOPM, 0, 0, &rt5631_hpl_mux_control), SND_SOC_DAPM_MUX("HPR Mux", SND_SOC_NOPM, 0, 0, &rt5631_hpr_mux_control), -SND_SOC_DAPM_PGA("Mono Amp", RT5631_PWR_MANAG_ADD3, 7, 0, NULL, 0), - - -SND_SOC_DAPM_PGA_E("SPKL Amp", VIRTUAL_POWER_CONTROL, 0, 0, NULL, 0, +SND_SOC_DAPM_PGA_E("Mono Amp", RT5631_PWR_MANAG_ADD3, 7, 0, NULL, 0, + mono_event, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), +SND_SOC_DAPM_PGA_E("SPKL Amp", SND_SOC_NOPM, 0, 0, NULL, 0, spk_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), -SND_SOC_DAPM_PGA_E("SPKR Amp", VIRTUAL_POWER_CONTROL, 1, 0, NULL, 0, +SND_SOC_DAPM_PGA_E("SPKR Amp", SND_SOC_NOPM, 1, 0, NULL, 0, spk_event, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_POST_PMU), -SND_SOC_DAPM_MICBIAS("Mic Bias1", RT5631_PWR_MANAG_ADD2, 3, 0), -SND_SOC_DAPM_MICBIAS("Mic Bias2", RT5631_PWR_MANAG_ADD2, 2, 0), - -SND_SOC_DAPM_OUTPUT("LOUT"), -SND_SOC_DAPM_OUTPUT("ROUT"), +SND_SOC_DAPM_OUTPUT("AUXO1"), +SND_SOC_DAPM_OUTPUT("AUXO2"), SND_SOC_DAPM_OUTPUT("SPOL"), SND_SOC_DAPM_OUTPUT("SPOR"), SND_SOC_DAPM_OUTPUT("HPOL"), SND_SOC_DAPM_OUTPUT("HPOR"), SND_SOC_DAPM_OUTPUT("MONO"), - }; static const struct snd_soc_dapm_route audio_map[] = { - {"Mic1 Boost", NULL, "MIC1"}, {"Mic2 Boost", NULL, "MIC2"}, {"MONOIN_RXP Boost", NULL, "MONOIN_RXP"}, @@ -1075,7 +1225,7 @@ static const struct snd_soc_dapm_route audio_map[] = { {"ADC Mixer", NULL, "RECMIXL Mixer"}, {"ADC Mixer", NULL, "RECMIXR Mixer"}, {"Left ADC", NULL, "ADC Mixer"}, - {"Right ADC", NULL,"ADC Mixer"}, + {"Right ADC", NULL, "ADC Mixer"}, {"Voice DAC Boost", NULL, "Voice DAC"}, @@ -1089,7 +1239,6 @@ static const struct snd_soc_dapm_route audio_map[] = { {"SPKMIXR Mixer", "MIC2_P Playback Switch", "MIC2"}, {"SPKMIXR Mixer", "RECMIXR Playback Switch", "RECMIXR Mixer"}, - {"OUTMIXL Mixer", "RECMIXL Playback Switch", "RECMIXL Mixer"}, {"OUTMIXL Mixer", "RECMIXR Playback Switch", "RECMIXR Mixer"}, {"OUTMIXL Mixer", "DACL Playback Switch", "Left DAC"}, @@ -1117,31 +1266,25 @@ static const struct snd_soc_dapm_route audio_map[] = { {"Right Out Vol", NULL, "OUTMIXR Mixer"}, {"Right HP Vol", NULL, "OUTMIXR Mixer"}, - {"AXO1MIX Mixer", "MIC1_BST1 Playback Switch", "Mic1 Boost"}, {"AXO1MIX Mixer", "OUTVOLL Playback Switch", "Left Out Vol"}, {"AXO1MIX Mixer", "OUTVOLR Playback Switch", "Right Out Vol"}, {"AXO1MIX Mixer", "MIC2_BST2 Playback Switch", "Mic2 Boost"}, - {"AXO2MIX Mixer", "MIC1_BST1 Playback Switch", "Mic1 Boost"}, {"AXO2MIX Mixer", "OUTVOLL Playback Switch", "Left Out Vol"}, {"AXO2MIX Mixer", "OUTVOLR Playback Switch", "Right Out Vol"}, {"AXO2MIX Mixer", "MIC2_BST2 Playback Switch", "Mic2 Boost"}, - {"SPOLMIX Mixer", "SPKVOLL Playback Switch", "Left SPK Vol"}, {"SPOLMIX Mixer", "SPKVOLR Playback Switch", "Right SPK Vol"}, {"SPORMIX Mixer", "SPKVOLL Playback Switch", "Left SPK Vol"}, {"SPORMIX Mixer", "SPKVOLR Playback Switch", "Right SPK Vol"}, - {"MONOMIX Mixer", "OUTVOLL Playback Switch", "Left Out Vol"}, {"MONOMIX Mixer", "OUTVOLR Playback Switch", "Right Out Vol"}, - - {"SPOL Mux", "SPOLMIX", "SPOLMIX Mixer"}, {"SPOL Mux", "MONOIN_RX", "MONO_IN"}, {"SPOL Mux", "VDAC", "Voice DAC Boost"}, @@ -1151,41 +1294,41 @@ static const struct snd_soc_dapm_route audio_map[] = { {"SPOR Mux", "MONOIN_RX", "MONO_IN"}, {"SPOR Mux", "VDAC", "Voice DAC Boost"}, {"SPOR Mux", "DACR", "Right DAC"}, - + {"Mono Mux", "MONOMIX", "MONOMIX Mixer"}, {"Mono Mux", "MONOIN_RX", "MONO_IN"}, {"Mono Mux", "VDAC", "Voice DAC Boost"}, {"Right DAC_HP", "NULL", "Right DAC"}, - {"Left DAC_HP", "NULL", "Left DAC"}, - + {"Left DAC_HP", "NULL", "Left DAC"}, + {"HPL Mux", "LEFT HPVOL", "Left HP Vol"}, - {"HPL Mux", "LEFT DAC", "Left DAC_HP"}, + {"HPL Mux", "LEFT DAC", "Left DAC_HP"}, {"HPR Mux", "RIGHT HPVOL", "Right HP Vol"}, - {"HPR Mux", "RIGHT DAC", "Right DAC_HP"}, + {"HPR Mux", "RIGHT DAC", "Right DAC_HP"}, {"SPKL Amp", NULL, "SPOL Mux"}, {"SPKR Amp", NULL, "SPOR Mux"}, {"Mono Amp", NULL, "Mono Mux"}, - - {"LOUT", NULL, "AXO1MIX Mixer"}, - {"ROUT", NULL, "AXO2MIX Mixer"}, + + {"AUXO1", NULL, "AXO1MIX Mixer"}, + {"AUXO2", NULL, "AXO2MIX Mixer"}, {"SPOL", NULL, "SPKL Amp"}, {"SPOR", NULL, "SPKR Amp"}, {"HPOL", NULL, "HPL Mux"}, - {"HPOR", NULL, "HPR Mux"}, + {"HPOR", NULL, "HPR Mux"}, {"MONO", NULL, "Mono Amp"} - }; static int rt5631_add_widgets(struct snd_soc_codec *codec) { - snd_soc_dapm_new_controls(codec, rt5631_dapm_widgets, - ARRAY_SIZE(rt5631_dapm_widgets)); - snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); - snd_soc_dapm_new_widgets(codec); + struct snd_soc_dapm_context *dapm = &codec->dapm; + + snd_soc_dapm_new_controls(dapm, rt5631_dapm_widgets, + ARRAY_SIZE(rt5631_dapm_widgets)); + snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); return 0; } @@ -1198,8 +1341,8 @@ static int voltab[2][16] = {0x1f, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, }; static int gvolume = 0; -#if 1 +#if 1 static int get_vol(int max, int min, int stage_num, int stage) { int ret, step=((max-min)<<8)/(stage_num-1); @@ -1224,14 +1367,10 @@ static int get_vol(int max, int min, int stage_num, int stage) static void rt5631_set_volume(int vollevel) { - struct snd_soc_device *socdev; - struct snd_soc_codec *codec; + struct snd_soc_codec *codec = rt5631_codec; int tmpvol1, tmpvol2; //DBG("rt5631_set_volume = %d\n", vollevel); - - socdev =rt5631_socdev; - codec = socdev->card->codec; if (vollevel > 15) vollevel = 8; gvolume = vollevel; @@ -1256,13 +1395,9 @@ static void rt5631_set_volume(int vollevel) static void rt5631_set_eq(int on) { - struct snd_soc_device *socdev; - struct snd_soc_codec *codec; + struct snd_soc_codec *codec = rt5631_codec; unsigned int Reg0C; - socdev =rt5631_socdev; - codec = socdev->card->codec; - Reg0C = rt5631_read(codec, RT5631_STEREO_DAC_VOL_1); DBG("------- rt5631_set_eq: read Reg0C = 0x%04x\n", Reg0C); @@ -1281,15 +1416,11 @@ static void rt5631_set_eq(int on) static void rt5631_set_volume(int vollevel) { - struct snd_soc_device *socdev; - struct snd_soc_codec *codec; + struct snd_soc_codec *codec = rt5631_codec; u8 tmpvol1, tmpvol2; u16 spk_vol, hp_vol; DBG("rt5631_set_volume = %d\n", vollevel); - - socdev =rt5631_socdev; - codec = socdev->card->codec; if (vollevel > 15) vollevel = 8; gvolume = vollevel; @@ -1313,141 +1444,147 @@ static void rt5631_set_volume(int vollevel) } #endif - -struct _coeff_div{ - unsigned int mclk; //pllout or MCLK - unsigned int bclk; //master mode - unsigned int rate; - unsigned int reg_val; +struct coeff_clk_div { + u32 mclk; + u32 bclk; + u32 rate; + u16 reg_val; }; -/*PLL divisors*/ -struct _pll_div { + +/* PLL divisors yes*/ +struct pll_div { u32 pll_in; u32 pll_out; - u16 regvalue; + u16 reg_val; }; -static const struct _pll_div codec_master_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}, - { 26000000, 24576000, 0x2027}, - { 26000000, 22579200, 0x392f}, - { 24576000, 22579200, 0x0921}, - { 24576000, 24576000, 0x02a0}, +static const struct pll_div codec_master_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}, + {26000000, 24576000, 0x2027}, + {26000000, 22579200, 0x392f}, + {24576000, 22579200, 0x0921}, + {24576000, 24576000, 0x02a0}, }; -static const struct _pll_div codec_slave_pll_div[] = { - { 256000, 4096000, 0x3ea0}, - { 352800, 5644800, 0x3ea0}, - { 512000, 8192000, 0x3ea0}, - { 705600, 11289600, 0x3ea0}, - { 1024000, 16384000, 0x3ea0}, - { 1411200, 22579200, 0x3ea0}, - { 1536000, 24576000, 0x3ea0}, - { 2048000, 16384000, 0x1ea0}, - { 2822400, 22579200, 0x1ea0}, - { 3072000, 24576000, 0x1ea0}, - { 705600, 11289600, 0x3ea0}, - { 705600, 8467200, 0x3ab0}, - { 24576000, 24576000, 0x02a0}, - { 1411200, 11289600, 0x1690}, - { 2822400, 11289600, 0x0a90}, - { 1536000, 12288000, 0x1690}, - { 3072000, 12288000, 0x0a90}, +static const struct pll_div codec_slave_pll_div[] = { + {256000, 2048000, 0x46f0}, + {256000, 4096000, 0x3ea0}, + {352800, 5644800, 0x3ea0}, + {512000, 8192000, 0x3ea0}, + {1024000, 8192000, 0x46f0}, + {705600, 11289600, 0x3ea0}, + {1024000, 16384000, 0x3ea0}, + {1411200, 22579200, 0x3ea0}, + {1536000, 24576000, 0x3ea0}, + {2048000, 16384000, 0x1ea0}, + {2822400, 22579200, 0x1ea0}, + {2822400, 45158400, 0x5ec0}, + {5644800, 45158400, 0x46f0}, + {3072000, 24576000, 0x1ea0}, + {3072000, 49152000, 0x5ec0}, + {6144000, 49152000, 0x46f0}, + {705600, 11289600, 0x3ea0}, + {705600, 8467200, 0x3ab0}, + {24576000, 24576000, 0x02a0}, + {1411200, 11289600, 0x1690}, + {2822400, 11289600, 0x0a90}, + {1536000, 12288000, 0x1690}, + {3072000, 12288000, 0x0a90}, }; -struct _coeff_div coeff_div[] = { - //sysclk is 256fs - { 2048000, 8000 * 32, 8000, 0x1000}, - { 2048000, 8000 * 64, 8000, 0x0000}, - { 2822400, 11025 * 32, 11025, 0x1000}, - { 2822400, 11025 * 64, 11025, 0x0000}, - { 4096000, 16000 * 32, 16000, 0x1000}, - { 4096000, 16000 * 64, 16000, 0x0000}, - { 5644800, 22050 * 32, 22050, 0x1000}, - { 5644800, 22050 * 64, 22050, 0x0000}, - { 8192000, 32000 * 32, 32000, 0x1000}, - { 8192000, 32000 * 64, 32000, 0x0000}, - {11289600, 44100 * 32, 44100, 0x1000}, - {11289600, 44100 * 64, 44100, 0x0000}, - {12288000, 48000 * 32, 48000, 0x1000}, - {12288000, 48000 * 64, 48000, 0x0000}, - //sysclk is 512fs - { 4096000, 8000 * 32, 8000, 0x3000}, - { 4096000, 8000 * 64, 8000, 0x2000}, - { 5644800, 11025 * 32, 11025, 0x3000}, - { 5644800, 11025 * 64, 11025, 0x2000}, - { 8192000, 16000 * 32, 16000, 0x3000}, - { 8192000, 16000 * 64, 16000, 0x2000}, - {11289600, 22050 * 32, 22050, 0x3000}, - {11289600, 22050 * 64, 22050, 0x2000}, - {16384000, 32000 * 32, 32000, 0x3000}, - {16384000, 32000 * 64, 32000, 0x2000}, - {22579200, 44100 * 32, 44100, 0x3000}, - {22579200, 44100 * 64, 44100, 0x2000}, - {24576000, 48000 * 32, 48000, 0x3000}, - {24576000, 48000 * 64, 48000, 0x2000}, - //sysclk is 24.576Mhz or 22.579200Mhz - {24576000, 8000 * 32, 8000, 0x7080}, - {24576000, 8000 * 64, 8000, 0x6080}, - {24576000, 16000 * 32, 16000, 0x5080}, - {24576000, 16000 * 64, 16000, 0x4080}, - {24576000, 24000 * 32, 24000, 0x5000}, - {24576000, 24000 * 64, 24000, 0x4000}, - {24576000, 32000 * 32, 32000, 0x3080}, - {24576000, 32000 * 64, 32000, 0x2080}, - - {22579200, 11025 * 32, 11025, 0x7000}, - {22579200, 11025 * 64, 11025, 0x6000}, - {22579200, 22050 * 32, 22050, 0x5000}, - {22579200, 22050 * 64, 22050, 0x4000}, - +struct coeff_clk_div coeff_div[] = { + /* sysclk is 256fs */ + {2048000, 8000 * 32, 8000, 0x1000}, + {2048000, 8000 * 64, 8000, 0x0000}, + {2822400, 11025 * 32, 11025, 0x1000}, + {2822400, 11025 * 64, 11025, 0x0000}, + {4096000, 16000 * 32, 16000, 0x1000}, + {4096000, 16000 * 64, 16000, 0x0000}, + {5644800, 22050 * 32, 22050, 0x1000}, + {5644800, 22050 * 64, 22050, 0x0000}, + {8192000, 32000 * 32, 32000, 0x1000}, + {8192000, 32000 * 64, 32000, 0x0000}, + {11289600, 44100 * 32, 44100, 0x1000}, + {11289600, 44100 * 64, 44100, 0x0000}, + {12288000, 48000 * 32, 48000, 0x1000}, + {12288000, 48000 * 64, 48000, 0x0000}, + {22579200, 88200 * 32, 88200, 0x1000}, + {22579200, 88200 * 64, 88200, 0x0000}, + {24576000, 96000 * 32, 96000, 0x1000}, + {24576000, 96000 * 64, 96000, 0x0000}, + /* sysclk is 512fs */ + {4096000, 8000 * 32, 8000, 0x3000}, + {4096000, 8000 * 64, 8000, 0x2000}, + {5644800, 11025 * 32, 11025, 0x3000}, + {5644800, 11025 * 64, 11025, 0x2000}, + {8192000, 16000 * 32, 16000, 0x3000}, + {8192000, 16000 * 64, 16000, 0x2000}, + {11289600, 22050 * 32, 22050, 0x3000}, + {11289600, 22050 * 64, 22050, 0x2000}, + {16384000, 32000 * 32, 32000, 0x3000}, + {16384000, 32000 * 64, 32000, 0x2000}, + {22579200, 44100 * 32, 44100, 0x3000}, + {22579200, 44100 * 64, 44100, 0x2000}, + {24576000, 48000 * 32, 48000, 0x3000}, + {24576000, 48000 * 64, 48000, 0x2000}, + {45158400, 88200 * 32, 88200, 0x3000}, + {45158400, 88200 * 64, 88200, 0x2000}, + {49152000, 96000 * 32, 96000, 0x3000}, + {49152000, 96000 * 64, 96000, 0x2000}, + /* sysclk is 24.576Mhz or 22.5792Mhz */ + {24576000, 8000 * 32, 8000, 0x7080}, + {24576000, 8000 * 64, 8000, 0x6080}, + {24576000, 16000 * 32, 16000, 0x5080}, + {24576000, 16000 * 64, 16000, 0x4080}, + {24576000, 24000 * 32, 24000, 0x5000}, + {24576000, 24000 * 64, 24000, 0x4000}, + {24576000, 32000 * 32, 32000, 0x3080}, + {24576000, 32000 * 64, 32000, 0x2080}, + {22579200, 11025 * 32, 11025, 0x7000}, + {22579200, 11025 * 64, 11025, 0x6000}, + {22579200, 22050 * 32, 22050, 0x5000}, + {22579200, 22050 * 64, 22050, 0x4000}, }; - - - static int get_coeff(int mclk, int rate, int timesofbclk) { int i; for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { - if ((coeff_div[i].mclk == mclk) - && (coeff_div[i].rate == rate) - && ((coeff_div[i].bclk / coeff_div[i].rate) == timesofbclk)) - return i; + if (coeff_div[i].mclk == mclk && coeff_div[i].rate == rate && + (coeff_div[i].bclk / coeff_div[i].rate) == timesofbclk) + return i; } - - return -1; + return -EINVAL; } static int get_coeff_in_slave_mode(int mclk, int rate) @@ -1457,223 +1594,221 @@ static int get_coeff_in_slave_mode(int mclk, int rate) static int get_coeff_in_master_mode(int mclk, int rate, int bclk) { - return get_coeff(mclk, rate, (bclk / rate)); + return get_coeff(mclk, rate, (bclk / rate)); } -static void rt5631_set_dmic_params(struct snd_soc_codec *codec, struct snd_pcm_hw_params *params) + +static void rt5631_set_dmic_params(struct snd_soc_codec *codec, + struct snd_pcm_hw_params *params) { -// struct rt5631_priv *rt5631 = codec->private_data; + int rate; - unsigned int rate; - - DBG( "enter %s\n", __func__); - rt5631_write_mask(codec, RT5631_GPIO_CTRL, GPIO_PIN_FUN_SEL_GPIO_DIMC|GPIO_DMIC_FUN_SEL_DIMC - , GPIO_PIN_FUN_SEL_MASK|GPIO_DMIC_FUN_SEL_MASK); + rt5631_write_mask(codec, RT5631_GPIO_CTRL, + GPIO_PIN_FUN_SEL_GPIO_DIMC | GPIO_DMIC_FUN_SEL_DIMC, + GPIO_PIN_FUN_SEL_MASK | GPIO_DMIC_FUN_SEL_MASK); rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, DMIC_ENA, DMIC_ENA_MASK); - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL,DMIC_L_CH_LATCH_FALLING|DMIC_R_CH_LATCH_RISING - ,DMIC_L_CH_LATCH_MASK|DMIC_R_CH_LATCH_MASK); + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_L_CH_LATCH_FALLING | DMIC_R_CH_LATCH_RISING, + DMIC_L_CH_LATCH_MASK|DMIC_R_CH_LATCH_MASK); rate = params_rate(params); switch (rate) { case 44100: case 48000: - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, DMIC_CLK_CTRL_TO_32FS, DMIC_CLK_CTRL_MASK); + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_CLK_CTRL_TO_32FS, DMIC_CLK_CTRL_MASK); break; + case 32000: case 22050: - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, DMIC_CLK_CTRL_TO_64FS, DMIC_CLK_CTRL_MASK); + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_CLK_CTRL_TO_64FS, DMIC_CLK_CTRL_MASK); break; + case 16000: case 11025: - case 8000: - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, DMIC_CLK_CTRL_TO_128FS, DMIC_CLK_CTRL_MASK); + case 8000: + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_CLK_CTRL_TO_128FS, DMIC_CLK_CTRL_MASK); + break; + + default: break; } - - rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, - DMIC_L_CH_UNMUTE | DMIC_R_CH_UNMUTE, DMIC_L_CH_MUTE_MASK | DMIC_R_CH_MUTE_MASK); - + + rt5631_write_mask(codec, RT5631_DIG_MIC_CTRL, + DMIC_L_CH_UNMUTE | DMIC_R_CH_UNMUTE, + DMIC_L_CH_MUTE_MASK | DMIC_R_CH_MUTE_MASK); + + return; } -static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) +static int rt5631_hifi_pcm_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 snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_device *socdev = rtd->socdev; - struct snd_soc_codec *codec = socdev->card->codec; - struct rt5631_priv *rt5631 = codec->private_data; - int stream = substream->stream; + struct snd_soc_codec *codec = rtd->codec; + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + int stream = substream->stream, rate = params_rate(params), coeff; unsigned int iface = 0; - int rate = params_rate(params); - int coeff = 0; - - DBG( "enter %s\n", __func__); + + pr_debug("enter %s\n", __func__); if (!rt5631->master) coeff = get_coeff_in_slave_mode(rt5631->sysclk, rate); else - coeff = get_coeff_in_master_mode(rt5631->sysclk, rate, rate * timesofbclk); + coeff = get_coeff_in_master_mode(rt5631->sysclk, rate, + rate * timesofbclk); + if (coeff < 0) + pr_err("%s: get coeff err!\n", __func__); - if (coeff < 0) { - DBG(KERN_ERR "%s get_coeff err!\n", __func__); - // return -EINVAL; + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S16_LE: + break; + case SNDRV_PCM_FORMAT_S20_3LE: + iface |= SDP_I2S_DL_20; + break; + case SNDRV_PCM_FORMAT_S24_LE: + iface |= SDP_I2S_DL_24; + break; + case SNDRV_PCM_FORMAT_S8: + iface |= SDP_I2S_DL_8; + break; + default: + return -EINVAL; } - switch (params_format(params)) - { - case SNDRV_PCM_FORMAT_S16_LE: - break; - case SNDRV_PCM_FORMAT_S20_3LE: - iface |= 0x0004; - break; - case SNDRV_PCM_FORMAT_S24_LE: - iface |= 0x0008; - break; - case SNDRV_PCM_FORMAT_S8: - iface |= 0x000c; - break; - default: - return -EINVAL; - } - - if (stream == SNDRV_PCM_STREAM_CAPTURE) { - if (rt5631->dmic_used_flag) //use Digital Mic + if (SNDRV_PCM_STREAM_CAPTURE == stream) { + if (rt5631->dmic_used_flag) rt5631_set_dmic_params(codec, params); } - + rt5631_write_mask(codec, RT5631_SDP_CTRL, iface, SDP_I2S_DL_MASK); - if(coeff>=0) - rt5631_write(codec, RT5631_STEREO_AD_DA_CLK_CTRL, coeff_div[coeff].reg_val); + if (coeff >= 0) + rt5631_write(codec, RT5631_STEREO_AD_DA_CLK_CTRL, + coeff_div[coeff].reg_val); -// if((rt5631_read(codec,RT5631_SPK_MONO_HP_OUT_CTRL)&0x000c)==0x000c) -// rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0x83e0, 0x8380); -// else - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0x83e0, 0x83e0); - - rt5631_write_mask(codec, 0x6e,0x4000,0x4000); -return 0; + return 0; } -static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) +static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) { struct snd_soc_codec *codec = codec_dai->codec; - struct rt5631_priv *rt5631 = codec->private_data; - u16 iface = 0; - - DBG( "enter %s\n", __func__); + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + unsigned int iface = 0; + + pr_debug("enter %s\n", __func__); + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: rt5631->master = 1; break; case SND_SOC_DAIFMT_CBS_CFS: - iface |= (0x0001 << 15); + iface |= SDP_MODE_SEL_SLAVE; rt5631->master = 0; break; default: return -EINVAL; } - + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: break; case SND_SOC_DAIFMT_LEFT_J: - iface |= (0x0001); + iface |= SDP_I2S_DF_LEFT; break; case SND_SOC_DAIFMT_DSP_A: - iface |= (0x0002); + iface |= SDP_I2S_DF_PCM_A; break; case SND_SOC_DAIFMT_DSP_B: - iface |= (0x0003); + iface |= SDP_I2S_DF_PCM_B; break; default: return -EINVAL; } - + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: break; case SND_SOC_DAIFMT_IB_NF: - iface |= (0x0001 << 7); + iface |= SDP_I2S_BCLK_POL_CTRL; break; default: - return -EINVAL; + return -EINVAL; } - + rt5631_write(codec, RT5631_SDP_CTRL, iface); return 0; } -static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai, - int clk_id, unsigned int freq, int dir) + +static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai, + int clk_id, unsigned int freq, int dir) { struct snd_soc_codec *codec = codec_dai->codec; - struct rt5631_priv *rt5631 = codec->private_data; - - DBG( "enter %s\n", __func__); - if ((freq >= (256 * 8000)) && (freq <= (512 * 48000))) { + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + + pr_info("enter %s, syclk=%d\n", __func__, freq); + if ((freq >= (256 * 8000)) && (freq <= (512 * 96000))) { rt5631->sysclk = freq; - return 0; + return 0; } - - DBG("unsupported sysclk freq %u for audio i2s\n", freq); - DBG("Set sysclk to 24.576Mhz by default\n"); + + pr_info("unsupported sysclk freq %u for audio i2s\n", freq); + pr_info("set sysclk to 24.576Mhz by default\n"); rt5631->sysclk = 24576000; - return 0; - //return -EINVAL; -} - -static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, - int pll_id, unsigned int freq_in, unsigned int freq_out) -{ - struct snd_soc_codec *codec = codec_dai->codec; - struct rt5631_priv *rt5631 = codec->private_data; - int i; - int ret = -EINVAL; - - - DBG( "enter %s\n", __func__); -// rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, 0, PWR_PLL); - - if (!freq_in || !freq_out) - return 0; - - if (rt5631->master) { - for (i = 0; i < ARRAY_SIZE(codec_master_pll_div); i ++) { - - if ((freq_in == codec_master_pll_div[i].pll_in) && (freq_out == codec_master_pll_div[i].pll_out)) { - - rt5631_write(codec, RT5631_PLL_CTRL, codec_master_pll_div[i].regvalue); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, PWR_PLL, PWR_PLL); - schedule_timeout_uninterruptible(msecs_to_jiffies(20)); - rt5631_write(codec, RT5631_GLOBAL_CLK_CTRL, 0x4000); - ret = 0; - - } - - } - } else { - - for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i ++) { - - if ((freq_in == codec_slave_pll_div[i].pll_in) && (freq_out == codec_slave_pll_div[i].pll_out)) { - - rt5631_write(codec, RT5631_PLL_CTRL, codec_slave_pll_div[i].regvalue); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, PWR_PLL, PWR_PLL); - schedule_timeout_uninterruptible(msecs_to_jiffies(20)); - rt5631_write(codec, RT5631_GLOBAL_CLK_CTRL, 0x5000); - ret = 0; - - } - - } - } - return 0; } +static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, + int source, unsigned int freq_in, unsigned int freq_out) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + int i, ret = -EINVAL; + + printk(KERN_DEBUG "enter %s\n", __func__); + + if (!freq_in || !freq_out) + return 0; + + if (rt5631->master) { + for (i = 0; i < ARRAY_SIZE(codec_master_pll_div); i++) + if (freq_in == codec_master_pll_div[i].pll_in && + freq_out == codec_master_pll_div[i].pll_out) { + rt5631_write(codec, RT5631_PLL_CTRL, + codec_master_pll_div[i].reg_val); + schedule_timeout_uninterruptible( + msecs_to_jiffies(20)); + rt5631_write(codec, RT5631_GLOBAL_CLK_CTRL, + SYSCLK_SOUR_SEL_PLL); + rt5631->pll_used_flag = 1; + ret = 0; + break; + } + } else { + for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++) + if (freq_in == codec_slave_pll_div[i].pll_in && + freq_out == codec_slave_pll_div[i].pll_out) { + rt5631_write(codec, RT5631_PLL_CTRL, + codec_slave_pll_div[i].reg_val); + schedule_timeout_uninterruptible( + msecs_to_jiffies(20)); + rt5631_write(codec, RT5631_GLOBAL_CLK_CTRL, + SYSCLK_SOUR_SEL_PLL | + PLLCLK_SOUR_SEL_BITCLK); + rt5631->pll_used_flag = 1; + ret = 0; + break; + } + } + + return ret; +} + +#if defined(CONFIG_ADJUST_VOL_BY_CODEC) static int rt5631_trigger(struct snd_pcm_substream *substream, int status, struct snd_soc_dai *dai) { //DBG("rt5631_trigger\n"); @@ -1694,560 +1829,334 @@ static int rt5631_trigger(struct snd_pcm_substream *substream, int status, struc return 0; } +#endif -static void rt5631_hifi_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai) +static ssize_t rt5631_index_reg_show(struct device *dev, + struct device_attribute *attr, char *buf) { - DBG( "enter %s\n", __func__); -} + #define IDX_REG_FMT "%02x: %04x\n" + #define IDX_REG_LEN 9 + unsigned int val; + int cnt = 0, i; -//#define RT5631_STEREO_RATES (SNDRV_PCM_RATE_8000_48000) -#define RT5631_STEREO_RATES (SNDRV_PCM_RATE_44100) // zyy 20110704, playback and record use same sample rate -#define RT5631_FORMAT (SNDRV_PCM_FMTBIT_S16_LE |\ - SNDRV_PCM_FMTBIT_S20_3LE |\ - SNDRV_PCM_FMTBIT_S24_LE |\ + cnt += sprintf(buf, "RT5631 index register\n"); + for (i = 0; i < 0x55; i++) { + if (cnt + IDX_REG_LEN >= PAGE_SIZE - 1) + break; + val = rt5631_read_index(rt5631_codec, i); + if (!val) + continue; + cnt += sprintf(buf + cnt, IDX_REG_FMT, i, val); + } + + if (cnt >= PAGE_SIZE) + cnt = PAGE_SIZE - 1; + + return cnt; +} +static DEVICE_ATTR(index_reg, 0444, rt5631_index_reg_show, NULL); + +#define RT5631_STEREO_RATES SNDRV_PCM_RATE_8000_96000 +#define RT5631_FORMAT (SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S20_3LE | \ + SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S8) struct snd_soc_dai_ops rt5631_ops = { - .hw_params = rt5631_hifi_pcm_params, - .set_fmt = rt5631_hifi_codec_set_dai_fmt, - .set_sysclk = rt5631_hifi_codec_set_dai_sysclk, - .set_pll = rt5631_codec_set_dai_pll, - .shutdown = rt5631_hifi_shutdown, + .hw_params = rt5631_hifi_pcm_params, + .set_fmt = rt5631_hifi_codec_set_dai_fmt, + .set_sysclk = rt5631_hifi_codec_set_dai_sysclk, + .set_pll = rt5631_codec_set_dai_pll, #if defined(CONFIG_ADJUST_VOL_BY_CODEC) - .trigger = rt5631_trigger, + .trigger = rt5631_trigger, #endif }; - -struct snd_soc_dai rt5631_dai[] = { + +struct snd_soc_dai_driver rt5631_dai[] = { { - .name = "RT5631 HIFI", - .id = 1, + .name = "RT5631 HiFi", .playback = { .stream_name = "HIFI Playback", .channels_min = 1, .channels_max = 2, .rates = RT5631_STEREO_RATES, - .formats = RT5631_FORMAT, - } , + .formats = RT5631_FORMAT, + }, .capture = { .stream_name = "HIFI Capture", .channels_min = 1, .channels_max = 2, - .rates = RT5631_STEREO_RATES, + .rates = RT5631_STEREO_RATES, .formats = RT5631_FORMAT, }, - .ops =&rt5631_ops, + .ops = &rt5631_ops, }, - - { - .name = "RT5631 Reserved", - .id = 2, - } }; - EXPORT_SYMBOL_GPL(rt5631_dai); - -static ssize_t rt5631_index_reg_show(struct device *dev, - struct device_attribute *attr, char *buf) +static int rt5631_set_bias_level(struct snd_soc_codec *codec, + enum snd_soc_bias_level level) { - struct snd_soc_device *socdev = dev_get_drvdata(dev); - struct snd_soc_codec *codec = socdev->card->codec; - int count = 0; - int value; - int i; - - count += sprintf(buf, "%s index register\n", codec->name); - - for (i = 0; i < 0x55; i++) { - count += sprintf(buf + count, "%2x= ", i); - if (count >= PAGE_SIZE - 1) - break; - value = rt5631_read_index(codec, i); - count += snprintf(buf + count, PAGE_SIZE - count, "0x%4x", value); - - if (count >= PAGE_SIZE - 1) - break; - - count += snprintf(buf + count, PAGE_SIZE - count, "\n"); - if (count >= PAGE_SIZE - 1) - break; - } - - if (count >= PAGE_SIZE) - count = PAGE_SIZE - 1; - - return count; - -} - -static DEVICE_ATTR(index_reg, 0444, rt5631_index_reg_show, NULL); - - -static int rt5631_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) -{ - DBG( "enter %s\n", __func__); - - DBG("rt5631_set_bias_level=%d\n",level); - switch (level) { case SND_SOC_BIAS_ON: break; - case SND_SOC_BIAS_PREPARE: - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3,PWR_VREF|PWR_MAIN_BIAS, PWR_VREF|PWR_MAIN_BIAS); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2,0x000c, 0x000c); - break; - case SND_SOC_BIAS_STANDBY: + case SND_SOC_BIAS_PREPARE: + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_VREF | PWR_MAIN_BIAS, PWR_VREF | PWR_MAIN_BIAS); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, + PWR_MICBIAS1_VOL | PWR_MICBIAS2_VOL, + PWR_MICBIAS1_VOL | PWR_MICBIAS2_VOL); break; + + case SND_SOC_BIAS_STANDBY: + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD2, 0, + PWR_MICBIAS1_VOL | PWR_MICBIAS2_VOL); + break; + case SND_SOC_BIAS_OFF: - rt5631_write_index(codec, 0x11,0x0000); - rt5631_write_mask(codec, RT5631_SPK_OUT_VOL ,0x8080, 0x8080); - rt5631_write_mask(codec, RT5631_HP_OUT_VOL ,0x8080, 0x8080); + rt5631_write_mask(codec, RT5631_SPK_OUT_VOL, + RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE); + rt5631_write_mask(codec, RT5631_HP_OUT_VOL, + RT_L_MUTE | RT_R_MUTE, RT_L_MUTE | RT_R_MUTE); rt5631_write(codec, RT5631_PWR_MANAG_ADD1, 0x0000); rt5631_write(codec, RT5631_PWR_MANAG_ADD2, 0x0000); rt5631_write(codec, RT5631_PWR_MANAG_ADD3, 0x0000); rt5631_write(codec, RT5631_PWR_MANAG_ADD4, 0x0000); break; + + default: + break; } - - codec->bias_level = level; + codec->dapm.bias_level = level; + return 0; } -static int rt5631_init(struct snd_soc_device *socdev) +static int rt5631_probe(struct snd_soc_codec *codec) { - struct snd_soc_codec *codec = socdev->card->codec; + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + unsigned int val; int ret; - - DBG( "enter %s\n", __func__); - codec->name = "RT5631"; - codec->owner = THIS_MODULE; - codec->read = rt5631_read; - codec->write = rt5631_write; - codec->set_bias_level = rt5631_set_bias_level; - codec->dai = rt5631_dai; - codec->num_dai = 2; - codec->reg_cache_size = ARRAY_SIZE(rt5631_reg); - codec->reg_cache_step = 1; - codec->reg_cache = kmemdup(rt5631_reg, sizeof(rt5631_reg), GFP_KERNEL); - - if (codec->reg_cache == NULL) - return -ENOMEM; - - ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); - if (ret < 0) { - DBG(KERN_ERR "rt5631: failed to create pcms\n"); - goto pcm_err; + 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; } - - rt5631_reset(codec); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3,PWR_VREF|PWR_MAIN_BIAS, PWR_VREF|PWR_MAIN_BIAS); - schedule_timeout_uninterruptible(msecs_to_jiffies(110)); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, PWR_FAST_VREF_CTRL, PWR_FAST_VREF_CTRL); - codec->bias_level = SND_SOC_BIAS_STANDBY; - schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(100)); + codec->cache_bypass = 1; + val = rt5631_read_index(codec, RT5631_ADDA_MIXER_INTL_REG3); + if (val & 0x0002) + rt5631->codec_version = 1; + else + rt5631->codec_version = 0; + + rt5631_reset(codec); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_VREF | PWR_MAIN_BIAS, PWR_VREF | PWR_MAIN_BIAS); + schedule_timeout_uninterruptible(msecs_to_jiffies(80)); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, PWR_FAST_VREF_CTRL, + PWR_FAST_VREF_CTRL); rt5631_reg_init(codec); -#if defined(CONFIG_ADJUST_VOL_BY_CODEC) - rt5631_set_volume(gvolume); -#endif -#if 0 //(RT5631_EQ_FUNC_ENA==1) - rt5631_write_index_mask(codec,0x11,0x0001,0x0003); - rt5631_write_index(codec,0x12,0x0001); - rt5631_update_eqmode(codec,HFREQ); - //rt5631_update_eqmode(codec,SPK_FR); -#endif + + /* power off ClassD auto Recovery */ + if (rt5631->codec_version) + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0x2000, 0x2000); + else + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0, 0x2000); + + codec->dapm.bias_level = SND_SOC_BIAS_STANDBY; + rt5631_codec = codec; + #if (RT5631_SPK_TIMER == 1) -/* Timer module installing */ - setup_timer( &spk_timer, spk_timer_callback, 0 ); - DBG( "Starting timer to fire in 5s (%ld)\n", jiffies ); - ret = mod_timer( &spk_timer, jiffies + msecs_to_jiffies(5000) ); - if (ret) printk("Error in mod_timer\n"); + /* Timer module installing */ + setup_timer( &spk_timer, spk_timer_callback, 0 ); + DBG( "Starting timer to fire in 5s (%ld)\n", jiffies ); + ret = mod_timer( &spk_timer, jiffies + msecs_to_jiffies(5000) ); + if (ret) printk("Error in mod_timer\n"); INIT_WORK(&spk_work, spk_work_handler); -#endif - rt5631_add_controls(codec); +#endif + + snd_soc_add_controls(codec, rt5631_snd_controls, + ARRAY_SIZE(rt5631_snd_controls)); rt5631_add_widgets(codec); - ret = snd_soc_init_card(socdev); - if (ret < 0) { - DBG(KERN_ERR "rt5631: failed to register card!\n"); - goto card_err; - } - DBG(KERN_INFO "rt5631 initial ok!\n"); - return 0; - - -card_err: - snd_soc_free_pcms(socdev); - snd_soc_dapm_free(socdev); -pcm_err: - kfree(codec->reg_cache); - codec->reg_cache = NULL; - return ret; -} - -static const struct i2c_device_id rt5631_i2c_id[] = { - {"rt5631", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, rt5631_i2c_id); - -static int rt5631_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct snd_soc_device *socdev = rt5631_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; - - DBG( "enter %s\n", __func__); - i2c_set_clientdata(i2c, codec); - codec->control_data = i2c; - - ret = rt5631_init(socdev); - if (ret < 0) - pr_err("failed to initialise rt5631!\n"); - - return ret; - - -} - -static int rt5631_i2c_remove(struct i2c_client *client) -{ - struct snd_soc_codec *codec = i2c_get_clientdata(client); - - DBG( "enter %s\n", __func__); - kfree(codec->reg_cache); - return 0; -} - -static void rt5631_i2c_shutdown(void){ - struct snd_soc_device *socdev = rt5631_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - - DBG( "enter %s\n", __func__); - rt5631_set_bias_level(codec, SND_SOC_BIAS_OFF); -} -struct i2c_driver rt5631_i2c_driver = { - .driver = { - .name = "RT5631 I2C Codec", - .owner = THIS_MODULE, - }, - .probe = rt5631_i2c_probe, - .remove = rt5631_i2c_remove, - .shutdown = rt5631_i2c_shutdown, - .id_table = rt5631_i2c_id, -}; - - -static int rt5631_add_i2c_device(struct platform_device *pdev, - const struct rt5631_setup_data *setup) -{ -#if 0 - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; -#endif - int ret; - - DBG( "enter %s\n", __func__); - ret = i2c_add_driver(&rt5631_i2c_driver); + ret = device_create_file(codec->dev, &dev_attr_index_reg); if (ret != 0) { - dev_err(&pdev->dev, "can't add i2c driver\n"); - return ret; - } - -#if 0 - memset(&info, '\0', sizeof(struct i2c_board_info)); - info.addr = setup->i2c_address; - info.platform_data = pdev; - strlcpy(info.type, "rt5631", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(setup->i2c_bus); - if (!adapter) { - dev_err(&pdev->dev, "can't get i2c adapter %d\n", - setup->i2c_bus); - goto err_driver; + dev_err(codec->dev, + "Failed to create index_reg sysfs files: %d\n", ret); + return ret; } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - goto err_driver; - } -#endif + + pr_info("RT5631 initial ok!\n"); return 0; - -#if 0 -err_driver: - i2c_del_driver(&rt5631_i2c_driver); - return -ENODEV; -#endif - } -static void rt5631_work(struct work_struct *work) +static int rt5631_remove(struct snd_soc_codec *codec) { - struct snd_soc_codec *codec = container_of(work, struct snd_soc_codec, delayed_work.work); - - rt5631_set_bias_level(codec, codec->bias_level); -} -static int rt5631_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct rt5631_setup_data *setup; - struct snd_soc_codec *codec; - struct rt5631_priv *rt5631; - int ret = 0; - - DBG( "enter %s\n", __func__); - pr_info("RT5631 Audio Codec %s", RT5631_VERSION); - - if(socdev->codec_data) - { - setup = socdev->codec_data; - } - - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) { - return -ENOMEM; - } - - - rt5631 = kzalloc(sizeof(struct rt5631_priv), GFP_KERNEL); - if (rt5631 == NULL) { - ret = -ENOMEM; - goto priv_err; - } - codec->private_data = rt5631; - socdev->card->codec = codec; - mutex_init(&codec->mutex); - rt5631_socdev = socdev; - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - INIT_DELAYED_WORK(&codec->delayed_work, rt5631_work); - - ret = device_create_file(&pdev->dev, &dev_attr_index_reg); - if (ret < 0) - printk(KERN_WARNING "asoc: failed to add index_reg sysfs files\n"); -#if 0 - if (setup->i2c_address) { - codec->hw_write = (hw_write_t)i2c_master_send; - - ret = rt5631_add_i2c_device(pdev, setup); - } -#else - //probe i2c device driver - { - codec->hw_write = (hw_write_t)i2c_master_send; - // codec->hw_read = (hw_read_t)i2c_master_recv; - ret = rt5631_add_i2c_device(pdev, setup); - } -#endif - - if (ret != 0) { - goto i2c_device_err; - } - return 0; - -i2c_device_err: - kfree(rt5631); - socdev->card->codec->private_data = NULL; - -priv_err: - kfree(codec); - socdev->card->codec = NULL; - - return ret; -} - -static int run_delayed_work(struct delayed_work *dwork) -{ - int ret; - - ret = cancel_delayed_work(dwork); - - if (ret) { - schedule_delayed_work(dwork, 0); - flush_scheduled_work(); - } - - return ret; -} - -static int rt5631_remove(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - - struct snd_soc_codec *codec =socdev->card->codec; #if (RT5631_SPK_TIMER == 1) -/* Timer¡¡module¡¡uninstalling */ + /* Timer¡¡module¡¡uninstalling */ int ret; - ret = del_timer(&spk_timer); - if(ret) printk("The timer is still in use...\n"); - DBG("Timer module uninstalling\n"); + ret = del_timer(&spk_timer); + if(ret) printk("The timer is still in use...\n"); + DBG("Timer module uninstalling\n"); #endif - if (codec->control_data) - rt5631_set_bias_level(codec, SND_SOC_BIAS_OFF); - run_delayed_work(&codec->delayed_work); - snd_soc_free_pcms(socdev); - snd_soc_dapm_free(socdev); - i2c_unregister_device(codec->control_data); - i2c_del_driver(&rt5631_i2c_driver); - kfree(codec->private_data); - kfree(codec); - - return 0; - -} -static int rt5631_suspend(struct platform_device *pdev, pm_message_t state) -{ - DBG( "enter %s\n", __func__); - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - - struct snd_soc_codec *codec =socdev->card->codec; rt5631_set_bias_level(codec, SND_SOC_BIAS_OFF); return 0; } -static int rt5631_resume(struct platform_device *pdev) +static int rt5631_suspend(struct snd_soc_codec *codec, pm_message_t state) { - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->card->codec; + rt5631_set_bias_level(codec, SND_SOC_BIAS_OFF); + return 0; +} -// int i; -// u8 data[3]; -// u16 *cache = codec->reg_cache; - -#if 1 - rt5631_reset(codec); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3,PWR_VREF|PWR_MAIN_BIAS, PWR_VREF|PWR_MAIN_BIAS); +static int rt5631_resume(struct snd_soc_codec *codec) +{ + struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_VREF | PWR_MAIN_BIAS, PWR_VREF | PWR_MAIN_BIAS); schedule_timeout_uninterruptible(msecs_to_jiffies(110)); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, PWR_FAST_VREF_CTRL, PWR_FAST_VREF_CTRL); + rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD3, + PWR_FAST_VREF_CTRL, PWR_FAST_VREF_CTRL); rt5631_reg_init(codec); -#if defined(CONFIG_ADJUST_VOL_BY_CODEC) - rt5631_set_volume(gvolume); -#endif - DBG( "enter %s\n", __func__); - rt5631_write_mask(codec, RT5631_PWR_MANAG_ADD1, 0x83e0, 0x83e0); -#if 0 //(RT5631_EQ_FUNC_ENA==1) - rt5631_write_index_mask(codec,0x11,0x0001,0x0003); - rt5631_write_index(codec,0x12,0x0001); - rt5631_update_eqmode(codec,HFREQ); - //rt5631_update_eqmode(codec,SPK_FR); -#endif + /* power off ClassD auto Recovery */ + if (rt5631->codec_version) + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0x2000, 0x2000); + else + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, + 0, 0x2000); + #if (RT5631_SPK_TIMER == 1) last_is_spk = !last_is_spk; //wired~, update eqmode right here by spk_timer. #endif -#else - for (i = 0; i < ARRAY_SIZE(rt5631_reg); i++) { - if (i == RT5631_RESET) - continue; - data[0] = i << 1; - data[1] = (0xff00 & cache[i]) >> 8; - data[2] = 0x00ff & cache[i]; - codec->hw_write(codec->control_data, data, 2); - } - - rt5631_set_bias_level(codec, SND_SOC_BIAS_STANDBY); -#endif - - if (codec->suspend_bias_level == SND_SOC_BIAS_ON) { - rt5631_set_bias_level(codec, SND_SOC_BIAS_PREPARE); - codec->bias_level = SND_SOC_BIAS_ON; - schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(100)); - } - - return 0; - + return 0; } void codec_set_spk(bool on) { - struct snd_soc_device *socdev; - struct snd_soc_codec *codec; - - socdev = rt5631_socdev; + struct snd_soc_codec *codec = rt5631_codec; DBG("%s: %d\n", __func__, on); - if(!socdev) - return; - - codec = socdev->card->codec; if(!codec) return; if(on){ DBG("snd_soc_dapm_enable_pin\n"); - snd_soc_dapm_enable_pin(codec, "Headphone Jack"); - snd_soc_dapm_enable_pin(codec, "Ext Spk"); + 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, "Headphone Jack"); - snd_soc_dapm_disable_pin(codec, "Ext Spk"); + snd_soc_dapm_disable_pin(&codec->dapm, "Headphone Jack"); + snd_soc_dapm_disable_pin(&codec->dapm, "Ext Spk"); } - snd_soc_dapm_sync(codec); + snd_soc_dapm_sync(&codec->dapm); return; } -//detect short current for mic1 +/* + * detect short current for mic1 + */ int rt5631_ext_mic_detect(void) { - int CodecValue; - struct snd_soc_device *socdev = rt5631_socdev; - struct snd_soc_codec *codec = socdev->card->codec; + struct snd_soc_codec *codec = rt5631_codec; + int det; - rt5631_write_mask(codec, RT5631_MIC_CTRL_2,MICBIAS1_S_C_DET_ENA,MICBIAS1_S_C_DET_MASK); - // rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2,0x2000,0x2000); - CodecValue=rt5631_read(codec,RT5631_INT_ST_IRQ_CTRL_2) & 0x0001; - - rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2,0x0001,0x00001); - - return CodecValue; + rt5631_write_mask(codec, RT5631_MIC_CTRL_2, MICBIAS1_S_C_DET_ENA, + MICBIAS1_S_C_DET_MASK); + det = rt5631_read(codec, RT5631_INT_ST_IRQ_CTRL_2) & 0x0001; + rt5631_write_mask(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0001, 0x00001); + return det; } - EXPORT_SYMBOL_GPL(rt5631_ext_mic_detect); - -struct snd_soc_codec_device soc_codec_dev_rt5631 = -{ +static struct snd_soc_codec_driver soc_codec_dev_rt5631 = { .probe = rt5631_probe, .remove = rt5631_remove, .suspend = rt5631_suspend, .resume = rt5631_resume, + .set_bias_level = rt5631_set_bias_level, + .reg_cache_size = ARRAY_SIZE(rt5631_reg), + .reg_word_size = sizeof(u16), + .reg_cache_default = rt5631_reg, + .reg_cache_step = 1, }; -EXPORT_SYMBOL_GPL(soc_codec_dev_rt5631); +static const struct i2c_device_id rt5631_i2c_id[] = { + { "rt5631", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, rt5631_i2c_id); + +static int rt5631_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct rt5631_priv *rt5631; + int ret; + + pr_info("RT5631 Audio Codec %s\n", RT5631_VERSION); + + rt5631 = kzalloc(sizeof(struct rt5631_priv), GFP_KERNEL); + if (NULL == rt5631) + return -ENOMEM; + + i2c_set_clientdata(i2c, rt5631); + + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5631, + rt5631_dai, ARRAY_SIZE(rt5631_dai)); + if (ret < 0) + kfree(rt5631); + + return ret; +} + +static __devexit int rt5631_i2c_remove(struct i2c_client *client) +{ + snd_soc_unregister_codec(&client->dev); + kfree(i2c_get_clientdata(client)); + return 0; +} + +struct i2c_driver rt5631_i2c_driver = { + .driver = { + .name = "RT5631", + .owner = THIS_MODULE, + }, + .probe = rt5631_i2c_probe, + .remove = __devexit_p(rt5631_i2c_remove), + .id_table = rt5631_i2c_id, +}; static int __init rt5631_modinit(void) { - return snd_soc_register_dais(rt5631_dai, ARRAY_SIZE(rt5631_dai)); + return i2c_add_driver(&rt5631_i2c_driver); } - -static void __exit rt5631_modexit(void) -{ - snd_soc_unregister_dais(rt5631_dai, ARRAY_SIZE(rt5631_dai)); -} - module_init(rt5631_modinit); + +static void __exit rt5631_modexit(void) +{ + i2c_del_driver(&rt5631_i2c_driver); +} module_exit(rt5631_modexit); + MODULE_DESCRIPTION("ASoC RT5631 driver"); -MODULE_AUTHOR("flove"); +MODULE_AUTHOR("flove "); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/rt5631.h b/sound/soc/codecs/rt5631.h index b2e316f08d25..e9bad16e40c8 100644 --- a/sound/soc/codecs/rt5631.h +++ b/sound/soc/codecs/rt5631.h @@ -1,578 +1,570 @@ -#ifndef __RTCODEC5631_H__ -#define __RTCODEC5631_H__ - - -#define RT5631_RESET 0X00 //RESET CODEC TO DEFAULT -#define RT5631_SPK_OUT_VOL 0X02 //SPEAKER OUT VOLUME -#define RT5631_HP_OUT_VOL 0X04 //HEADPHONE OUTPUT VOLUME -#define RT5631_MONO_AXO_1_2_VOL 0X06 //MONO/AUXOUT OUTPUT VOLUME -#define RT5631_AUX_IN_VOL 0X0A //AUX IN VOLUME -#define RT5631_STEREO_DAC_VOL_1 0X0C //STEREO DAC VOLUME 1 -#define RT5631_MIC_CTRL_1 0X0E //MICROPHONE CONTROL 1 -#define RT5631_STEREO_DAC_VOL_2 0X10 //STEREO DAC VOLUME 2 -#define RT5631_ADC_CTRL_1 0X12 //STEREO ADC CONTROL 1 -#define RT5631_ADC_REC_MIXER 0X14 //ADC RECORD MIXER CONTROL -#define RT5631_ADC_CTRL_2 0X16 //STEREO ADC CONTROL 2 -#define RT5631_OUTMIXER_L_CTRL 0X1A //LEFT OUTPUT MIXER CONTROL -#define RT5631_OUTMIXER_R_CTRL 0X1C //RIGHT OUTPUT MIXER CONTROL -#define RT5631_AXO1MIXER_CTRL 0X1E //LOUT MIXER CONTROL -#define RT5631_AXO2MIXER_CTRL 0X20 //LOUT MIXER CONTROL -#define RT5631_MIC_CTRL_2 0X22 //MICROPHONE CONTROL 2 -#define RT5631_DIG_MIC_CTRL 0X24 //DIGITAL MICROPHONE CONTROL -#define RT5631_MONO_INPUT_VOL 0X26 //MONO INPUT VOLUME -#define RT5631_SPK_MIXER_CTRL 0X28 //SPEAKER MIXER CONTROL -#define RT5631_SPK_MONO_OUT_CTRL 0X2A //SPEAKER/MONO OUTPUT CONTROL -#define RT5631_SPK_MONO_HP_OUT_CTRL 0X2C //SPEAKER/MONO/HP OUTPUT CONTROL -#define RT5631_SDP_CTRL 0X34 //STEREO I2S SERIAL DATA PORT CONTROL -#define RT5631_STEREO_AD_DA_CLK_CTRL 0X38 //STEREO AD/DA CLOCK CONTROL -#define RT5631_PWR_MANAG_ADD1 0X3A //POWER MANAGMENT ADDITION 1 -#define RT5631_PWR_MANAG_ADD2 0X3B //POWER MANAGMENT ADDITION 2 -#define RT5631_PWR_MANAG_ADD3 0X3C //POWER MANAGMENT ADDITION 3 -#define RT5631_PWR_MANAG_ADD4 0X3E //POWER MANAGMENT ADDITION 4 -#define RT5631_GEN_PUR_CTRL_REG 0X40 //GENERAL PURPOSE CONTROL REGISTER -#define RT5631_GLOBAL_CLK_CTRL 0X42 //GLOBAL CLOCK CONTROL -#define RT5631_PLL_CTRL 0X44 //PLL CONTROL -#define RT5631_INT_ST_IRQ_CTRL_1 0X48 //INTERNAL STATUS AND IRQ CONTROL 1 -#define RT5631_INT_ST_IRQ_CTRL_2 0X4A //INTERNAL STATUS AND IRQ CONTROL 2 -#define RT5631_GPIO_CTRL 0X4C //GPIO OUTPUT CONTROL -#define RT5631_MISC_CTRL 0X52 //MISC CONTROL -#define RT5631_DEPOP_FUN_CTRL_1 0X54 //DE-POP FUNCTION CONTROL 1 -#define RT5631_DEPOP_FUN_CTRL_2 0X56 //DE-POP FUNCTION CONTROL 2 -#define RT5631_JACK_DET_CTRL 0X5A //JACK DETECT CONTROL REGISTER -#define RT5631_SOFT_VOL_CTRL 0X5C //SOFT VOLUME CONTROL -#define RT5631_ALC_CTRL_1 0X64 //ALC CONTROL 1 -#define RT5631_ALC_CTRL_2 0X65 //ALC CONTROL 2 -#define RT5631_ALC_CTRL_3 0X66 //ALC CONTROL 3 -#define RT5631_PSEUDO_SPATL_CTRL 0X68 //PSEUDO STEREO AND SPATIAL EFFECT CONTROL -#define RT5631_INDEX_ADD 0X6A //INDEX ADDRESS -#define RT5631_INDEX_DATA 0X6C //INDEX DATA -#define RT5631_EQ_CTRL 0X6E //EQ CONTROL -#define RT5631_VENDOR_ID1 0x7C //VENDOR ID1 -#define RT5631_VENDOR_ID2 0x7E //VENDOR ID2 - - -//global definition -#define RT_L_MUTE (0x1<<15) //MUTE LEFT CONTROL BIT -#define RT_R_MUTE (0x1<<7) //MUTE RIGHT CONTROL BIT - -//Speaker Output Control(0x02) -#define SPK_L_VOL_SEL_MASK (0x1<<14) //Speaker left channel volume input select MASK -#define SPK_L_VOL_SEL_VMID (0x0<<14) //Speaker left channel volume input select VMID -#define SPK_L_VOL_SEL_SPKMIX_L (0x1<<14) //Speaker left channel volume input select SPKMIXER LEFT -#define SPK_R_VOL_SEL_MASK (0x1<< 6) //Speaker right channel volume input select MASK -#define SPK_R_VOL_SEL_VMID (0x0<< 6) //Speaker right channel volume input select VMID -#define SPK_R_VOL_SEL_SPKMIX_R (0x1<< 6) //Speaker right channel volume input select SPKMIXER RIGHT - -//Headphone Output Control(0x04) -#define HP_L_VOL_SEL_MASK (0x1<<14) //HP left channel volume input select MASK -#define HP_L_VOL_SEL_VMID (0x0<<14) //HP left channel volume input select VMID -#define HP_L_VOL_SEL_OUTMIX_L (0x1<<14) //HP left channel volume input select OUTMIXER LEFT -#define HP_R_VOL_SEL_MASK (0x1<< 6) //HP right channel volume input select MASK -#define HP_R_VOL_SEL_VMID (0x0<< 6) //HP right channel volume input select VMID -#define HP_R_VOL_SEL_OUTMIX_R (0x1<< 6) //HP right channel volume input select OUTMIXER RIGHT - - -//Output Control for AUXOUT/MONO(0x06) -#define AUXOUT_1_VOL_SEL_MASK (0x1<<14) //LOUT channel volume input select MASK -#define AUXOUT_1_VOL_SEL_VMID (0x0<<14) //LOUT channel volume input select VMID -#define AUXOUT_1_VOL_SEL_OUTMIX_L (0x1<<14) //LOUT channel volume input select OUTMIXER LEFT -#define MUTE_MONO (0x1<<13) //Mute Mono control -#define AUXOUT_2_VOL_SEL_MASK (0x1<< 6) //ROUT channel volume input select MASK -#define AUXOUT_2_VOL_SEL_VMID (0x0<< 6) //ROUT channel volume input select VMID -#define AUXOUT_2_VOL_SEL_OUTMIX_R (0x1<< 6) //ROUT channel volume input select OUTMIXER RIGHT - - -//Microphone Input Control 1(0x0E) -#define MIC1_DIFF_INPUT_CTRL (0x1<<15) //MIC1 different input control -#define MIC2_DIFF_INPUT_CTRL (0x1<< 7) //MIC2 different input control - - -//ADC Recording Mixer Control(0x14) -#define M_OUTMIXER_L_TO_RECMIXER_L (0x1<<15) //Mute left OUTMIXER to left RECMIXER -#define M_MIC1_TO_RECMIXER_L (0x1<<14) //Mute mic1 to left RECMIXER -#define M_AXIL_TO_RECMIXER_L (0x1<<13) //Mute AXIL to left RECMIXER -#define M_MONO_IN_TO_RECMIXER_L (0x1<<12) //Mute BB_RX to left RECMIXER -#define M_OUTMIXER_R_TO_RECMIXER_R (0x1<< 7) //Mute right OUTMIXER to right RECMIXER -#define M_MIC2_TO_RECMIXER_R (0x1<< 6) //Mute mic2 to right RECMIXER -#define M_AXIR_TO_RECMIXER_R (0x1<< 5) //Mute AXIR to right RECMIXER -#define M_MONO_IN_TO_RECMIXER_R (0x1<< 4) //Mute BB_RX to right RECMIXER - -//Left Output Mixer Control(0x1A) -#define M_RECMIXER_L_TO_OUTMIXER_L (0x1<<15) //Mute Left RecMixer to Left OutMixer -#define M_RECMIXER_R_TO_OUTMIXER_L (0x1<<14) //Mute Right RecMixer to Left OutMixer -#define M_DAC_L_TO_OUTMIXER_L (0x1<<13) //Mute Left Dac to Left OutMixer -#define M_MIC1_TO_OUTMIXER_L (0x1<<12) //Mute Mic1 to Left OutMixer -#define M_MIC2_TO_OUTMIXER_L (0x1<<11) //Mute Mic2 to Left OutMixer -#define M_MONO_IN_P_TO_OUTMIXER_L (0x1<<10) //Mute MONO IN positive to Left OutMixer -#define M_AXIL_TO_OUTMIXER_L (0x1<< 9) //Mute AXIL to Left OutMixer -#define M_AXIR_TO_OUTMIXER_L (0x1<< 8) //Mute AXIR to Left OutMixer - - -//Right Output Mixer Control(0x1C) -#define M_RECMIXER_L_TO_OUTMIXER_R (0x1<<15) //Mute Left RecMixer to Right OutMixer -#define M_RECMIXER_R_TO_OUTMIXER_R (0x1<<14) //Mute Right RecMixer to Right OutMixer -#define M_DAC_R_TO_OUTMIXER_R (0x1<<13) //Mute Left Dac to Right OutMixer -#define M_MIC1_TO_OUTMIXER_R (0x1<<12) //Mute Mic1 to Right OutMixer -#define M_MIC2_TO_OUTMIXER_R (0x1<<11) //Mute Mic2 to Right OutMixer -#define M_MONO_IN_N_TO_OUTMIXER_R (0x1<<10) //Mute MONO IN Negative to Right OutMixer -#define M_AXIL_TO_OUTMIXER_R (0x1<< 9) //Mute AXIL to Right OutMixer -#define M_AXIR_TO_OUTMIXER_R (0x1<< 8) //Mute AXIR to Right OutMixer - - -//Lout Mixer Control(0x1E) -#define M_MIC1_TO_AXO1MIXER (0x1<<15) //Mute MIC1 to LOUT Mixer -#define M_MIC2_TO_AXO1MIXER (0x1<<11) //Mute MIC2 to LOUT Mixer -#define M_OUTMIXER_L_TO_AXO1MIXER (0x1<< 7) //Mute Left Output mixer to LOUT Mixer -#define M_OUTMIXER_R_TO_AXO1MIXER (0x1<< 6) //Mute Right Output mixer to LOUT Mixer - - -//Rout Mixer Control(0x20) -#define M_MIC1_TO_AXO2MIXER (0x1<<15) //Mute MIC1 to ROUT Mixer -#define M_MIC2_TO_AXO2MIXER (0x1<<11) //Mute MIC2 to ROUT Mixer -#define M_OUTMIXER_L_TO_AXO2MIXER (0x1<< 7) //Mute Left Output mixer to ROUT Mixer -#define M_OUTMIXER_R_TO_AXO2MIXER (0x1<< 6) //Mute Right Output mixer to ROUT Mixer - -//Micphone Input Control 2(0x22) -#define MIC_BIAS_90_PRECNET_AVDD 1 -#define MIC_BIAS_75_PRECNET_AVDD 2 - -#define MIC1_BOOST_CTRL_MASK (0xf<<12) -#define MIC1_BOOST_CTRL_BYPASS (0x0<<12) -#define MIC1_BOOST_CTRL_20DB (0x1<<12) -#define MIC1_BOOST_CTRL_24DB (0x2<<12) -#define MIC1_BOOST_CTRL_30DB (0x3<<12) -#define MIC1_BOOST_CTRL_35DB (0x4<<12) -#define MIC1_BOOST_CTRL_40DB (0x5<<12) -#define MIC1_BOOST_CTRL_34DB (0x6<<12) -#define MIC1_BOOST_CTRL_50DB (0x7<<12) -#define MIC1_BOOST_CTRL_52DB (0x8<<12) - -#define MIC2_BOOST_CTRL_MASK (0xf<< 8) -#define MIC2_BOOST_CTRL_BYPASS (0x0<< 8) -#define MIC2_BOOST_CTRL_20DB (0x1<< 8) -#define MIC2_BOOST_CTRL_24DB (0x2<< 8) -#define MIC2_BOOST_CTRL_30DB (0x3<< 8) -#define MIC2_BOOST_CTRL_35DB (0x4<< 8) -#define MIC2_BOOST_CTRL_40DB (0x5<< 8) -#define MIC2_BOOST_CTRL_34DB (0x6<< 8) -#define MIC2_BOOST_CTRL_50DB (0x7<< 8) -#define MIC2_BOOST_CTRL_52DB (0x8<< 8) - -#define MICBIAS1_VOLT_CTRL_MASK (0x1<< 7) -#define MICBIAS1_VOLT_CTRL_90P (0x0<< 7) -#define MICBIAS1_VOLT_CTRL_75P (0x1<< 7) - -#define MICBIAS1_S_C_DET_MASK (0x1<< 6) -#define MICBIAS1_S_C_DET_DIS (0x0<< 6) -#define MICBIAS1_S_C_DET_ENA (0x1<< 6) - -#define MICBIAS1_SHORT_CURR_DET_MASK (0x3<< 4) -#define MICBIAS1_SHORT_CURR_DET_600UA (0x0<< 4) -#define MICBIAS1_SHORT_CURR_DET_1500UA (0x1<< 4) -#define MICBIAS1_SHORT_CURR_DET_2000UA (0x2<< 4) - -#define MICBIAS2_VOLT_CTRL_MASK (0x1<< 3) -#define MICBIAS2_VOLT_CTRL_90P (0x0<< 3) -#define MICBIAS2_VOLT_CTRL_75P (0x1<< 3) - -#define MICBIAS2_S_C_DET_MASK (0x1<< 2) -#define MICBIAS2_S_C_DET_DIS (0x0<< 2) -#define MICBIAS2_S_C_DET_ENA (0x1<< 2) - -#define MICBIAS2_SHORT_CURR_DET_MASK (0x3) -#define MICBIAS2_SHORT_CURR_DET_600UA (0x0) -#define MICBIAS2_SHORT_CURR_DET_1500UA (0x1) -#define MICBIAS2_SHORT_CURR_DET_2000UA (0x2) - - -//Digital Microphone Control(0x24) -#define DMIC_ENA_MASK (0x1<<15) -#define DMIC_ENA (0x1<<15) //use DMIC to ADC Digital filter -#define DMIC_DIS (0x0<<15) //use ADC mixer to ADC Digital filter - -#define DMIC_L_CH_MUTE_MASK (0x1<<13) -#define DMIC_L_CH_UNMUTE (0x0<<13) -#define DMIC_L_CH_MUTE (0x1<<13) - -#define DMIC_R_CH_MUTE_MASK (0x1<<12) -#define DMIC_R_CH_UNMUTE (0x0<<12) -#define DMIC_R_CH_MUTE (0x1<<12) - -#define DMIC_L_CH_LATCH_MASK (0x1<< 9) -#define DMIC_L_CH_LATCH_RISING (0x1<< 9) -#define DMIC_L_CH_LATCH_FALLING (0x0<< 9) - -#define DMIC_R_CH_LATCH_MASK (0x1<< 8) -#define DMIC_R_CH_LATCH_RISING (0x1<< 8) -#define DMIC_R_CH_LATCH_FALLING (0x0<< 8) - -#define DMIC_CLK_CTRL_MASK (0x3<<4) -#define DMIC_CLK_CTRL_TO_128FS (0x0<<4) -#define DMIC_CLK_CTRL_TO_64FS (0x1<<4) -#define DMIC_CLK_CTRL_TO_32FS (0x2<<4) - - -//Speaker Mixer Control(0x28) -#define M_RECMIXER_L_TO_SPKMIXER_L (0x1<<15) //Mute Left RecMixer to Left Speaker Mixer -#define M_MIC1_P_TO_SPKMIXER_L (0x1<<14) //Mute MIC1 Positive to Left Speaker Mixer -#define M_DAC_L_TO_SPKMIXER_L (0x1<<13) //Mute Left Dac to Left Speaker Mixer -#define M_OUTMIXER_L_TO_SPKMIXER_L (0x1<<12) //Mute Left OutMixer to Left Speaker Mixer - -#define M_RECMIXER_R_TO_SPKMIXER_R (0x1<< 7) //Mute Right RecMixer to Right Speaker Mixer -#define M_MIC2_P_TO_SPKMIXER_R (0x1<< 6) //Mute MIC1 Positive to Right Speaker Mixer -#define M_DAC_R_TO_SPKMIXER_R (0x1<< 5) //Mute Right Dac to Right Speaker Mixer -#define M_OUTMIXER_R_TO_SPKMIXER_R (0x1<< 4) //Mute Right OutMixer to Right Speaker Mixer - - - -//Speaker/Mono Output Control(0x2A) -#define M_SPKVOL_L_TO_SPOL_MIXER (0x1<<15) //Mute Left Speaker Volume to SPOL Mixer -#define M_SPKVOL_R_TO_SPOL_MIXER (0x1<<14) //Mute Right Speaker Volume to SPOL Mixer -#define M_SPKVOL_L_TO_SPOR_MIXER (0x1<<13) //Mute Left Speaker Volume to SPOR Mixer -#define M_SPKVOL_R_TO_SPOR_MIXER (0x1<<12) //Mute Right Speaker Volume to SPOR Mixer -#define M_OUTVOL_L_TO_MONOMIXER (0x1<<11) //Mute Left Output Volume to Mono Mixer -#define M_OUTVOL_R_TO_MONOMIXER (0x1<<10) //Mute Right Output Volume to Mono Mixer - - -//Speaker/Mono/HP Output Control(0x2C) -#define SPK_L_MUX_SEL_MASK (0x3<<14) //Left Speaker mux select Mask -#define SPK_L_MUX_SEL_SPKMIXER_L (0x0<<14) //Left Speaker mux select Speaker mixer left -#define SPK_L_MUX_SEL_MONO_IN (0x1<<14) //Left Speaker mux select MONO input -#define SPK_L_MUX_SEL_DAC_L (0x3<<14) //Left Speaker mux select Dac left - -#define SPK_R_MUX_SEL_MASK (0x3<<10) //Right Speaker mux select Mask -#define SPK_R_MUX_SEL_SPKMIXER_R (0x0<<10) //Right Speaker mux select Speaker mixer right -#define SPK_R_MUX_SEL_MONO_IN (0x1<<10) //Right Speaker mux select MONO input -#define SPK_R_MUX_SEL_DAC_R (0x3<<10) //Right Speaker mux select Dac right - -#define MONO_MUX_SEL_MASK (0x3<< 6) //Monoout mux select Mask -#define MONO_MUX_SEL_MONOMIXER (0x0<< 6) //Monoout mux select Mono Mixer -#define MONO_MUX_SEL_MONO_IN (0x1<< 6) //Monoout mux select MONO input - -#define HP_L_MUX_SEL_MASK (0x1<< 3) //HP left mux select Mask -#define HP_L_MUX_SEL_HPVOL_L (0x0<< 3) //HP left mux select left HP output volume -#define HP_L_MUX_SEL_DAC_L (0x1<< 3) //HP left mux select Dac left channel - -#define HP_R_MUX_SEL_MASK (0x1<< 2) //HP left mux select Mask -#define HP_R_MUX_SEL_HPVOL_R (0x0<< 2) //HP left mux select left HP output volume -#define HP_R_MUX_SEL_DAC_R (0x1<< 2) //HP left mux select Dac left channel - - -//Stereo I2S Serial Data Port Control(0x34) -#define SDP_MODE_SEL_MASK (0x1<<15) //Main I2S interface select MASK -#define SDP_MODE_SEL_MASTER (0x0<<15) //Main I2S interface select MASTER MODE -#define SDP_MODE_SEL_SLAVE (0x1<<15) //Main I2S interface select SLAVE MODE - -#define SDP_ADC_CPS_SEL_MASK (0x3<<10) //ADC Compress select Mask -#define SDP_ADC_CPS_SEL_OFF (0x0<<10) //ADC Compress select OFF -#define SDP_ADC_CPS_SEL_U_LAW (0x1<<10) //ADC Compress select u_law -#define SDP_ADC_CPS_SEL_A_LAW (0x2<<10) //ADC Compress select a_law - -#define SDP_DAC_CPS_SEL_MASK (0x3<< 8) //DAC Compress select Mask -#define SDP_DAC_CPS_SEL_OFF (0x0<< 8) //DAC Compress select OFF -#define SDP_DAC_CPS_SEL_U_LAW (0x1<< 8) //DAC Compress select u_law -#define SDP_DAC_CPS_SEL_A_LAW (0x2<< 8) //DAC Compress select a_law - -#define SDP_I2S_BCLK_POL_CTRL (0x1<<7) //0:Normal 1:Invert - -#define SDP_DAC_R_INV (0x1<<6) //0:Normal 1:Invert - -#define SDP_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 SDP_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 SDP_I2S_DL_MASK (0x3<<2) //Stereo Serial Data Length mask -#define SDP_I2S_DL_16 (0x0<<2) //16 bits -#define SDP_I2S_DL_20 (0x1<<2) //20 bits -#define SDP_I2S_DL_24 (0x2<<2) //24 bits -#define SDP_I2S_DL_8 (0x3<<2) //8 bits - -//PCM Data Format Selection -#define SDP_I2S_DF_MASK (0x3) //main i2s Data Format mask -#define SDP_I2S_DF_I2S (0x0) //I2S FORMAT -#define SDP_I2S_DF_LEFT (0x1) //Left JUSTIFIED -#define SDP_I2S_DF_PCM_A (0x2) //PCM format A -#define SDP_I2S_DF_PCM_B (0x3) //PCM format B - -//Stereo AD/DA Clock Control(0x38h) -#define I2S_PRE_DIV_MASK (0x7<<13) -#define I2S_PRE_DIV_1 (0x0<<13) //DIV 1 -#define I2S_PRE_DIV_2 (0x1<<13) //DIV 2 -#define I2S_PRE_DIV_4 (0x2<<13) //DIV 4 -#define I2S_PRE_DIV_8 (0x3<<13) //DIV 8 -#define I2S_PRE_DIV_16 (0x4<<13) //DIV 16 -#define I2S_PRE_DIV_32 (0x5<<13) //DIV 32 - -#define I2S_LRCK_SEL_N_BCLK_MASK (0x1<<12) //CLOCK RELATIVE OF BCLK AND LCRK -#define I2S_LRCK_SEL_64_BCLK (0x0<<12) //64FS -#define I2S_LRCK_SEL_32_BCLK (0x1<<12) //32FS - -#define DAC_OSR_SEL_MASK (0x3<<10) -#define DAC_OSR_SEL_128FS (0x3<<10) -#define DAC_OSR_SEL_64FS (0x3<<10) -#define DAC_OSR_SEL_32FS (0x3<<10) -#define DAC_OSR_SEL_16FS (0x3<<10) - -#define ADC_OSR_SEL_MASK (0x3<< 8) -#define ADC_OSR_SEL_128FS (0x3<< 8) -#define ADC_OSR_SEL_64FS (0x3<< 8) -#define ADC_OSR_SEL_32FS (0x3<< 8) -#define ADC_OSR_SEL_16FS (0x3<< 8) - -#define ADDA_FILTER_CLK_SEL_256FS (0<<7) //256FS -#define ADDA_FILTER_CLK_SEL_384FS (1<<7) //384FS - - - -//Power managment addition 1 (0x3A),0:Disable,1:Enable -#define PWR_MAIN_I2S_EN (0x1<<15) -#define PWR_CLASS_D (0x1<<12) -#define PWR_ADC_L_CLK (0x1<<11) -#define PWR_ADC_R_CLK (0x1<<10) -#define PWR_DAC_L_CLK (0x1<< 9) -#define PWR_DAC_R_CLK (0x1<< 8) -#define PWR_DAC_REF (0x1<< 7) -#define PWR_DAC_L_TO_MIXER (0x1<< 6) -#define PWR_DAC_R_TO_MIXER (0x1<<5) - - -//Power managment addition 2 (0x3B),0:Disable,1:Enable -#define PWR_OUTMIXER_L (0x1<<15) -#define PWR_OUTMIXER_R (0x1<<14) -#define PWR_SPKMIXER_L (0x1<<13) -#define PWR_SPKMIXER_R (0x1<<12) -#define PWR_RECMIXER_L (0x1<<11) -#define PWR_RECMIXER_R (0x1<<10) -#define PWR_MIC1_BOOT_GAIN (0x1<< 5) -#define PWR_MIC2_BOOT_GAIN (0x1<< 4) -#define PWR_MICBIAS1_VOL (0x1<< 3) -#define PWR_MICBIAS2_VOL (0x1<< 2) -#define PWR_PLL (0x1<< 1) - - -//Power managment addition 3(0x3C),0:Disable,1:Enable -#define PWR_VREF (0x1<<15) -#define PWR_FAST_VREF_CTRL (0x1<<14) -#define PWR_MAIN_BIAS (0x1<<13) -#define PWR_AXO1MIXER (0x1<<11) -#define PWR_AXO2MIXER (0x1<<10) -#define PWR_MONOMIXER (0x1<< 9) -#define PWR_MONO_DEPOP_DIS (0x1<< 8) -#define PWR_MONO_AMP_EN (0x1<< 7) -#define PWR_CHARGE_PUMP (0x1<<4) -#define PWR_HP_L_AMP (0x1<<3) -#define PWR_HP_R_AMP (0x1<<2) -#define PWR_HP_DEPOP_DIS (0x1<<1) -#define PWR_HP_AMP_DRIVING (0x1) - - -//Power managment addition 4(0x3E),0:Disable,1:Enable -#define PWR_SPK_L_VOL (0x1<<15) -#define PWR_SPK_R_VOL (0x1<<14) -#define PWR_LOUT_VOL (0x1<<13) -#define PWR_ROUT_VOL (0x1<<12) -#define PWR_HP_L_OUT_VOL (0x1<<11) -#define PWR_HP_R_OUT_VOL (0x1<<10) -#define PWR_AXIL_IN_VOL (0x1<< 9) -#define PWR_AXIR_IN_VOL (0x1<< 8) -#define PWR_MONO_IN_P_VOL (0x1<< 7) -#define PWR_MONO_IN_N_VOL (0x1<< 6) - - -//General Purpose Control Register(0x40) -#define SPK_AMP_AUTO_RATIO_EN (0x1<<15) //Speaker Amplifier Auto Ratio Gain Control - -#define SPK_AMP_RATIO_CTRL_MASK (0x7<<12) -#define SPK_AMP_RATIO_CTRL_2_34 (0x0<<12) //7.40DB -#define SPK_AMP_RATIO_CTRL_1_99 (0x1<<12) //5.99DB -#define SPK_AMP_RATIO_CTRL_1_68 (0x2<<12) //4.50DB -#define SPK_AMP_RATIO_CTRL_1_56 (0x3<<12) //3.86DB -#define SPK_AMP_RATIO_CTRL_1_44 (0x4<<12) //3.16DB -#define SPK_AMP_RATIO_CTRL_1_27 (0x5<<12) //2.10DB -#define SPK_AMP_RATIO_CTRL_1_09 (0x6<<12) //0.80DB -#define SPK_AMP_RATIO_CTRL_1_00 (0x7<<12) //0.00DB - -#define STEREO_DAC_HI_PASS_FILT_EN (0x1<<11) //Stereo DAC high pass filter enable -#define STEREO_ADC_HI_PASS_FILT_EN (0x1<<10) //Stereo ADC high pass filter enable - -#define ADC_WIND_FILT_MASK (0x3<<4) //Select ADC Wind Filter Clock type -#define ADC_WIND_FILT_8_16_32K (0x0<<4) //8/16/32k -#define ADC_WIND_FILT_11_22_44K (0x1<<4) //11/22/44k -#define ADC_WIND_FILT_12_24_48K (0x2<<4) //12/24/48k - -#define ADC_WIND_FILT_EN (0x1<<3) //Enable ADC Wind Filter - -#define ADC_WIND_CNR_FREQ_MASK (0x7<<0) //SelectADC Wind Filter Corner Frequency -#define ADC_WIND_CNR_FREQ_82_113_122 (0x0<<0) //82/113/122 Hz -#define ADC_WIND_CNR_FREQ_102_141_153 (0x1<<0) //102/141/153 Hz -#define ADC_WIND_CNR_FREQ_131_180_156 (0x2<<0) //131/180/156 Hz -#define ADC_WIND_CNR_FREQ_163_225_245 (0x3<<0) //163/225/245 Hz -#define ADC_WIND_CNR_FREQ_204_281_306 (0x4<<0) //204/281/306 Hz -#define ADC_WIND_CNR_FREQ_261_360_392 (0x5<<0) //261/360/392 Hz -#define ADC_WIND_CNR_FREQ_327_450_490 (0x6<<0) //327/450/490 Hz -#define ADC_WIND_CNR_FREQ_408_563_612 (0x7<<0) //408/563/612 Hz - - -//Global Clock Control Register(0x42) -#define SYSCLK_SOUR_SEL_MASK (0x1<<14) -#define SYSCLK_SOUR_SEL_MCLK (0x0<<14) //system Clock source from MCLK -#define SYSCLK_SOUR_SEL_PLL (0x1<<14) //system Clock source from PLL -#define SYSCLK_SOUR_SEL_PLL_TCK (0x2<<14) //system Clock source from PLL track - -#define PLLCLK_SOUR_SEL_MCLK (0x0<<12) //PLL clock source from MCLK -#define PLLCLK_SOUR_SEL_BITCLK (0x1<<12) //PLL clock source from BITCLK - -#define PLLCLK_PRE_DIV1 (0x0<<11) //DIV 1 -#define PLLCLK_PRE_DIV2 (0x1<<11) //DIV 2 - -//PLL Control(0x44) - -#define PLL_CTRL_M_VAL(m) ((m)&0xf) //M code for analog PLL -#define PLL_CTRL_K_VAL(k) (((k)&0x7)<<4) //K code for analog PLL -#define PLL_CTRL_N_VAL(n) (((n)&0xff)<<8) //N code for analog PLL - - -//GPIO Pin Configuration(0x4C) -#define GPIO_PIN_FUN_SEL_MASK (0x1<<15) -#define GPIO_PIN_FUN_SEL_IRQ (0x1<<15) //GPIO pin SELECT IRQ -#define GPIO_PIN_FUN_SEL_GPIO_DIMC (0x0<<15) //GPIO PIN SELECT GPIO_DMIC - - -#define GPIO_DMIC_FUN_SEL_MASK (0x1<<3) -#define GPIO_DMIC_FUN_SEL_DIMC (0x1<<3) //GPIO pin SELECT DMIC -#define GPIO_DMIC_FUN_SEL_GPIO (0x0<<3) //GPIO PIN SELECT GPIO - -#define GPIO_PIN_CON_MASK (0x1<<2) -#define GPIO_PIN_SET_INPUT (0x0<<2) //GPIO pin select input -#define GPIO_PIN_SET_OUTPUT (0x1<<2) //GPIO pin select output - -//De-POP function Control 1(0x54) -#define POW_ON_SOFT_GEN (0x1<<15) //POWER ON SOFT GENERATOR -#define EN_MUTE_UNMUTE_DEPOP (0x1<<14) //Enable mute/unmute depop -#define EN_DEPOP2_FOR_HP (0x1<<7) //Enable depop 2 for HP -#define PD_HPAMP_L_ST_UP (0x1<<5) //Power Down HPAMP_L Starts Up Signal -#define PD_HPAMP_R_ST_UP (0x1<<4) //Power Down HPAMP_R Starts Up Signal -#define EN_HP_L_M_UN_MUTE_DEPOP (0x1<<1) //Enable left HP mute/unmute depop -#define EN_HP_R_M_UN_MUTE_DEPOP (0x1<<0) //Enable right HP mute/unmute depop - -//De-POP Fnction Control(0x56) -#define ENA_CAP_FREE_DEPOP (0x1<<14) //enable depop for Capfree block - - -//Jack Detect Control Register(0x5A) -#define JD_USE_MASK (0x3<<14) //JD Pin select -#define JD_USE_JD2 (0x3<<14) //select JD2 -#define JD_USE_JD1 (0x2<<14) //select JD1 -#define JD_USE_GPIO (0x1<<14) //select GPIO -#define JD_OFF (0x0<<14) //off - -#define JD_HP_EN (0x1<<11) //JD trigger enable for HP -#define JD_HP_TRI_MASK (0x1<<10) //Trigger mask -#define JD_HP_TRI_HI (0x1<<10) //high trigger -#define JD_HP_TRI_LO (0x1<<10) //low trigger - -#define JD_SPK_L_EN (0x1<<9) //JD trigger enable for speaker LP/LN -#define JD_SPK_L_TRI_MASK (0x1<<8) //Trigger mask -#define JD_SPK_L_TRI_HI (0x1<<8) //high trigger -#define JD_SPK_L_TRI_LO (0x0<<8) //low trigger - -#define JD_SPK_R_EN (0x1<<7) //JD trigger enable for speaker RP/RN -#define JD_SPK_R_TRI_MASK (0x1<<6) //Trigger mask -#define JD_SPK_R_TRI_HI (0x1<<6) //high trigger -#define JD_SPK_R_TRI_LO (0x0<<6) //low trigger - -#define JD_MONO_EN (0x1<<5) //JD trigger enable for monoout -#define JD_MONO_TRI_MASK (0x1<<4) //Trigger mask -#define JD_MONO_TRI_HI (0x1<<4) //high trigger -#define JD_MONO_TRI_LO (0x0<<4) //low trigger - -#define JD_AUX_1_EN (0x1<<3) //JD trigger enable for Lout -#define JD_AUX_1_MASK (0x1<<2) //Trigger mask -#define JD_AUX_1_TRI_HI (0x1<<2) //high trigger -#define JD_AUX_1_TRI_LO (0x0<<2) //low trigger - -#define JD_AUX_2_EN (0x1<<1) //JD trigger enable for Rout - -#define JD_AUX_2_MASK (0x1<<0) //Trigger mask -#define JD_AUX_2_TRI_HI (0x1<<0) //high trigger -#define JD_AUX_2_TRI_LO (0x0<<0) //low trigger - - -////ALC CONTROL 1(0x64) -#define ALC_ATTACK_RATE_MASK (0x1F<<8) //select ALC attack rate -#define ALC_RECOVERY_RATE_MASK (0x1F<<0) //select ALC Recovery rate - - -////ALC CONTROL 2(0x65) -#define ALC_COM_NOISE_GATE_MASK (0xF<<0) //select Compensation gain for Noise gate function - - -////ALC CONTROL 3(0x66) -#define ALC_FUN_MASK (0x3<<14) //select ALC path -#define ALC_FUN_DIS (0x0<<14) //disable -#define ALC_ENA_DAC_PATH (0x1<<14) //DAC path -#define ALC_ENA_ADC_PATH (0x3<<14) //ADC path - -#define ALC_PARA_UPDATE (0x1<<13) //update ALC parameter - -#define ALC_LIMIT_LEVEL_MASK (0x1F<<8) //ALC limit level - -#define ALC_NOISE_GATE_FUN_MASK (0x1<<7) //ALC noise gate function -#define ALC_NOISE_GATE_FUN_DIS (0x0<<7) //disable -#define ALC_NOISE_GATE_FUN_ENA (0x1<<7) //enable - -#define ALC_NOISE_GATE_H_D_MASK (0x1<<6) //ALC noise gate hold data function -#define ALC_NOISE_GATE_H_D_DIS (0x0<<6) //disable -#define ALC_NOISE_GATE_H_D_ENA (0x1<<6) //enable - -//Psedueo Stereo & Spatial Effect Block Control(0x68) -#define SPATIAL_CTRL_EN (0x1<<15) //enable Spatial effect -#define ALL_PASS_FILTER_EN (0x1<<14) //enable all pass filter -#define PSEUDO_STEREO_EN (0x1<<13) //enable pseudo stereo block -#define STEREO_EXPENSION_EN (0x1<<12) //enable stereo expansion block - -#define GAIN_3D_PARA_MASK (0x3<<6) //3D gain parameter -#define GAIN_3D_PARA_1_00 (0x0<<6) //3D gain 1.0 -#define GAIN_3D_PARA_1_50 (0x1<<6) //3D gain 1.5 -#define GAIN_3D_PARA_2_00 (0x2<<6) //3D gain 2.0 - -#define RATIO_3D_MASK (0x3<<4) //3D ratio parameter -#define RATIO_3D_0_0 (0x0<<4) //3D ratio 0.0 -#define RATIO_3D_0_66 (0x1<<4) //3D ratio 0.66 -#define RATIO_3D_1_0 (0x2<<4) //3D ratio 1.0 - -#define APF_FUN_SLE_MASK (0x3<<0) //select samplerate for all pass filter -#define APF_FUN_SEL_48K (0x3<<0) //select 48k -#define APF_FUN_SEL_44_1K (0x2<<0) //select 44.1k -#define APF_FUN_SEL_32K (0x1<<0) //select 32k -#define APF_FUN_DIS (0x0<<0) //disable - - -//EQ CONTROL 1(0x6E) - -#define HW_EQ_PATH_SEL_MASK (0x1<<15) //HW EQ FUN SEL -#define HW_EQ_PATH_SEL_DAC (0x0<<15) //HW EQ FOR DAC PATH -#define HW_EQ_PATH_SEL_ADC (0x1<<15) //HW EQ FOR ADC PATH - -#define HW_EQ_UPDATE_CTRL (0x1<<14) //HW EQ Update CTRL - -#define EN_HW_EQ_HPF2 (0x1<<5) //EQ High Pass Filter 2 Control -#define EN_HW_EQ_HPF1 (0x1<<4) //EQ High Pass Filter 1 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 - -#define REALTEK_HWDEP 0 -struct rt5631_setup_data { - int i2c_address; - int i2c_bus; -}; - - -extern struct snd_soc_dai rt5631_dai[]; -extern struct snd_soc_codec_device soc_codec_dev_rt5631; - - -#endif //__RTCODEC5631_H__ +#ifndef __RTCODEC5631_H__ +#define __RTCODEC5631_H__ + + +#define RT5631_RESET 0x00 +#define RT5631_SPK_OUT_VOL 0x02 +#define RT5631_HP_OUT_VOL 0x04 +#define RT5631_MONO_AXO_1_2_VOL 0x06 +#define RT5631_AUX_IN_VOL 0x0A +#define RT5631_STEREO_DAC_VOL_1 0x0C +#define RT5631_MIC_CTRL_1 0x0E +#define RT5631_STEREO_DAC_VOL_2 0x10 +#define RT5631_ADC_CTRL_1 0x12 +#define RT5631_ADC_REC_MIXER 0x14 +#define RT5631_ADC_CTRL_2 0x16 +#define RT5631_OUTMIXER_L_CTRL 0x1A +#define RT5631_OUTMIXER_R_CTRL 0x1C +#define RT5631_AXO1MIXER_CTRL 0x1E +#define RT5631_AXO2MIXER_CTRL 0x20 +#define RT5631_MIC_CTRL_2 0x22 +#define RT5631_DIG_MIC_CTRL 0x24 +#define RT5631_MONO_INPUT_VOL 0x26 +#define RT5631_SPK_MIXER_CTRL 0x28 +#define RT5631_SPK_MONO_OUT_CTRL 0x2A +#define RT5631_SPK_MONO_HP_OUT_CTRL 0x2C +#define RT5631_SDP_CTRL 0x34 +#define RT5631_STEREO_AD_DA_CLK_CTRL 0x38 +#define RT5631_PWR_MANAG_ADD1 0x3A +#define RT5631_PWR_MANAG_ADD2 0x3B +#define RT5631_PWR_MANAG_ADD3 0x3C +#define RT5631_PWR_MANAG_ADD4 0x3E +#define RT5631_GEN_PUR_CTRL_REG 0x40 +#define RT5631_GLOBAL_CLK_CTRL 0x42 +#define RT5631_PLL_CTRL 0x44 +#define RT5631_INT_ST_IRQ_CTRL_1 0x48 +#define RT5631_INT_ST_IRQ_CTRL_2 0x4A +#define RT5631_GPIO_CTRL 0x4C +#define RT5631_MISC_CTRL 0x52 +#define RT5631_DEPOP_FUN_CTRL_1 0x54 +#define RT5631_DEPOP_FUN_CTRL_2 0x56 +#define RT5631_JACK_DET_CTRL 0x5A +#define RT5631_SOFT_VOL_CTRL 0x5C +#define RT5631_ALC_CTRL_1 0x64 +#define RT5631_ALC_CTRL_2 0x65 +#define RT5631_ALC_CTRL_3 0x66 +#define RT5631_PSEUDO_SPATL_CTRL 0x68 +#define RT5631_INDEX_ADD 0x6A +#define RT5631_INDEX_DATA 0x6C +#define RT5631_EQ_CTRL 0x6E +#define RT5631_VENDOR_ID1 0x7C +#define RT5631_VENDOR_ID2 0x7E + +/* Index of Codec Private Register definition */ +#define RT5631_EQ_BW_LOP 0x00 +#define RT5631_EQ_GAIN_LOP 0x01 +#define RT5631_EQ_FC_BP1 0x02 +#define RT5631_EQ_BW_BP1 0x03 +#define RT5631_EQ_GAIN_BP1 0x04 +#define RT5631_EQ_FC_BP2 0x05 +#define RT5631_EQ_BW_BP2 0x06 +#define RT5631_EQ_GAIN_BP2 0x07 +#define RT5631_EQ_FC_BP3 0x08 +#define RT5631_EQ_BW_BP3 0x09 +#define RT5631_EQ_GAIN_BP3 0x0a +#define RT5631_EQ_BW_HIP 0x0b +#define RT5631_EQ_GAIN_HIP 0x0c +#define RT5631_EQ_HPF_A1 0x0d +#define RT5631_EQ_HPF_A2 0x0e +#define RT5631_EQ_HPF_GAIN 0x0f +#define RT5631_EQ_PRE_VOL_CTRL 0x11 +#define RT5631_EQ_POST_VOL_CTRL 0x12 +#define RT5631_TEST_MODE_CTRL 0x39 +#define RT5631_CP_INTL_REG2 0x45 +#define RT5631_ADDA_MIXER_INTL_REG3 0x52 +#define RT5631_SPK_INTL_CTRL 0x56 + + +/* global definition */ +#define RT_L_MUTE (0x1 << 15) +#define RT_R_MUTE (0x1 << 7) + +/* Speaker Output Control(0x02) */ +#define SPK_L_VOL_SEL_MASK (0x1 << 14) +#define SPK_L_VOL_SEL_VMID (0x0 << 14) +#define SPK_L_VOL_SEL_SPKMIX_L (0x1 << 14) +#define SPK_R_VOL_SEL_MASK (0x1 << 6) +#define SPK_R_VOL_SEL_VMID (0x0 << 6) +#define SPK_R_VOL_SEL_SPKMIX_R (0x1 << 6) + +/* Headphone Output Control(0x04) */ +#define HP_L_VOL_SEL_MASK (0x1 << 14) +#define HP_L_VOL_SEL_VMID (0x0 << 14) +#define HP_L_VOL_SEL_OUTMIX_L (0x1 << 14) +#define HP_R_VOL_SEL_MASK (0x1 << 6) +#define HP_R_VOL_SEL_VMID (0x0 << 6) +#define HP_R_VOL_SEL_OUTMIX_R (0x1 << 6) + +/* Output Control for AUXOUT/MONO(0x06) */ +#define AUXOUT_1_VOL_SEL_MASK (0x1 << 14) +#define AUXOUT_1_VOL_SEL_VMID (0x0 << 14) +#define AUXOUT_1_VOL_SEL_OUTMIX_L (0x1 << 14) +#define MUTE_MONO (0x1 << 13) +#define AUXOUT_2_VOL_SEL_MASK (0x1 << 6) +#define AUXOUT_2_VOL_SEL_VMID (0x0 << 6) +#define AUXOUT_2_VOL_SEL_OUTMIX_R (0x1 << 6) + +/* Microphone Input Control 1(0x0E) */ +#define MIC1_DIFF_INPUT_CTRL (0x1 << 15) +#define MIC2_DIFF_INPUT_CTRL (0x1 << 7) + +/* ADC Recording Mixer Control(0x14) */ +#define M_OUTMIXER_L_TO_RECMIXER_L (0x1 << 15) +#define M_MIC1_TO_RECMIXER_L (0x1 << 14) +#define M_AXIL_TO_RECMIXER_L (0x1 << 13) +#define M_MONO_IN_TO_RECMIXER_L (0x1 << 12) +#define M_OUTMIXER_R_TO_RECMIXER_R (0x1 << 7) +#define M_MIC2_TO_RECMIXER_R (0x1 << 6) +#define M_AXIR_TO_RECMIXER_R (0x1 << 5) +#define M_MONO_IN_TO_RECMIXER_R (0x1 << 4) + +/* Left Output Mixer Control(0x1A) */ +#define M_RECMIXER_L_TO_OUTMIXER_L (0x1 << 15) +#define M_RECMIXER_R_TO_OUTMIXER_L (0x1 << 14) +#define M_DAC_L_TO_OUTMIXER_L (0x1 << 13) +#define M_MIC1_TO_OUTMIXER_L (0x1 << 12) +#define M_MIC2_TO_OUTMIXER_L (0x1 << 11) +#define M_MONO_IN_P_TO_OUTMIXER_L (0x1 << 10) +#define M_AXIL_TO_OUTMIXER_L (0x1 << 9) +#define M_AXIR_TO_OUTMIXER_L (0x1 << 8) + +/* Right Output Mixer Control(0x1C) */ +#define M_RECMIXER_L_TO_OUTMIXER_R (0x1 << 15) +#define M_RECMIXER_R_TO_OUTMIXER_R (0x1 << 14) +#define M_DAC_R_TO_OUTMIXER_R (0x1 << 13) +#define M_MIC1_TO_OUTMIXER_R (0x1 << 12) +#define M_MIC2_TO_OUTMIXER_R (0x1 << 11) +#define M_MONO_IN_N_TO_OUTMIXER_R (0x1 << 10) +#define M_AXIL_TO_OUTMIXER_R (0x1 << 9) +#define M_AXIR_TO_OUTMIXER_R (0x1 << 8) + +/* Lout Mixer Control(0x1E) */ +#define M_MIC1_TO_AXO1MIXER (0x1 << 15) +#define M_MIC2_TO_AXO1MIXER (0x1 << 11) +#define M_OUTMIXER_L_TO_AXO1MIXER (0x1 << 7) +#define M_OUTMIXER_R_TO_AXO1MIXER (0x1 << 6) + +/* Rout Mixer Control(0x20) */ +#define M_MIC1_TO_AXO2MIXER (0x1 << 15) +#define M_MIC2_TO_AXO2MIXER (0x1 << 11) +#define M_OUTMIXER_L_TO_AXO2MIXER (0x1 << 7) +#define M_OUTMIXER_R_TO_AXO2MIXER (0x1 << 6) + +/* Micphone Input Control 2(0x22) */ +#define MIC_BIAS_90_PRECNET_AVDD 1 +#define MIC_BIAS_75_PRECNET_AVDD 2 + +#define MIC1_BOOST_CTRL_MASK (0xf << 12) +#define MIC1_BOOST_CTRL_BYPASS (0x0 << 12) +#define MIC1_BOOST_CTRL_20DB (0x1 << 12) +#define MIC1_BOOST_CTRL_24DB (0x2 << 12) +#define MIC1_BOOST_CTRL_30DB (0x3 << 12) +#define MIC1_BOOST_CTRL_35DB (0x4 << 12) +#define MIC1_BOOST_CTRL_40DB (0x5 << 12) +#define MIC1_BOOST_CTRL_34DB (0x6 << 12) +#define MIC1_BOOST_CTRL_50DB (0x7 << 12) +#define MIC1_BOOST_CTRL_52DB (0x8 << 12) + +#define MIC2_BOOST_CTRL_MASK (0xf << 8) +#define MIC2_BOOST_CTRL_BYPASS (0x0 << 8) +#define MIC2_BOOST_CTRL_20DB (0x1 << 8) +#define MIC2_BOOST_CTRL_24DB (0x2 << 8) +#define MIC2_BOOST_CTRL_30DB (0x3 << 8) +#define MIC2_BOOST_CTRL_35DB (0x4 << 8) +#define MIC2_BOOST_CTRL_40DB (0x5 << 8) +#define MIC2_BOOST_CTRL_34DB (0x6 << 8) +#define MIC2_BOOST_CTRL_50DB (0x7 << 8) +#define MIC2_BOOST_CTRL_52DB (0x8 << 8) + +#define MICBIAS1_VOLT_CTRL_MASK (0x1 << 7) +#define MICBIAS1_VOLT_CTRL_90P (0x0 << 7) +#define MICBIAS1_VOLT_CTRL_75P (0x1 << 7) + +#define MICBIAS1_S_C_DET_MASK (0x1 << 6) +#define MICBIAS1_S_C_DET_DIS (0x0 << 6) +#define MICBIAS1_S_C_DET_ENA (0x1 << 6) + +#define MICBIAS1_SHORT_CURR_DET_MASK (0x3 << 4) +#define MICBIAS1_SHORT_CURR_DET_600UA (0x0 << 4) +#define MICBIAS1_SHORT_CURR_DET_1500UA (0x1 << 4) +#define MICBIAS1_SHORT_CURR_DET_2000UA (0x2 << 4) + +#define MICBIAS2_VOLT_CTRL_MASK (0x1 << 3) +#define MICBIAS2_VOLT_CTRL_90P (0x0 << 3) +#define MICBIAS2_VOLT_CTRL_75P (0x1 << 3) + +#define MICBIAS2_S_C_DET_MASK (0x1 << 2) +#define MICBIAS2_S_C_DET_DIS (0x0 << 2) +#define MICBIAS2_S_C_DET_ENA (0x1 << 2) + +#define MICBIAS2_SHORT_CURR_DET_MASK (0x3) +#define MICBIAS2_SHORT_CURR_DET_600UA (0x0) +#define MICBIAS2_SHORT_CURR_DET_1500UA (0x1) +#define MICBIAS2_SHORT_CURR_DET_2000UA (0x2) + + +/* Digital Microphone Control(0x24) */ +#define DMIC_ENA_MASK (0x1 << 15) +/* DMIC_ENA: DMIC to ADC Digital filter */ +#define DMIC_ENA (0x1 << 15) +/* DMIC_DIS: ADC mixer to ADC Digital filter */ +#define DMIC_DIS (0x0 << 15) + +#define DMIC_L_CH_MUTE_MASK (0x1 << 13) +#define DMIC_L_CH_UNMUTE (0x0 << 13) +#define DMIC_L_CH_MUTE (0x1 << 13) + +#define DMIC_R_CH_MUTE_MASK (0x1 << 12) +#define DMIC_R_CH_UNMUTE (0x0 << 12) +#define DMIC_R_CH_MUTE (0x1 << 12) + +#define DMIC_L_CH_LATCH_MASK (0x1 << 9) +#define DMIC_L_CH_LATCH_RISING (0x1 << 9) +#define DMIC_L_CH_LATCH_FALLING (0x0 << 9) + +#define DMIC_R_CH_LATCH_MASK (0x1 << 8) +#define DMIC_R_CH_LATCH_RISING (0x1 << 8) +#define DMIC_R_CH_LATCH_FALLING (0x0 << 8) + +#define DMIC_CLK_CTRL_MASK (0x3 << 4) +#define DMIC_CLK_CTRL_TO_128FS (0x0 << 4) +#define DMIC_CLK_CTRL_TO_64FS (0x1 << 4) +#define DMIC_CLK_CTRL_TO_32FS (0x2 << 4) + +/* Speaker Mixer Control(0x28) */ +#define M_RECMIXER_L_TO_SPKMIXER_L (0x1 << 15) +#define M_MIC1_P_TO_SPKMIXER_L (0x1 << 14) +#define M_DAC_L_TO_SPKMIXER_L (0x1 << 13) +#define M_OUTMIXER_L_TO_SPKMIXER_L (0x1 << 12) + +#define M_RECMIXER_R_TO_SPKMIXER_R (0x1 << 7) +#define M_MIC2_P_TO_SPKMIXER_R (0x1 << 6) +#define M_DAC_R_TO_SPKMIXER_R (0x1 << 5) +#define M_OUTMIXER_R_TO_SPKMIXER_R (0x1 << 4) + +/* Speaker/Mono Output Control(0x2A) */ +#define M_SPKVOL_L_TO_SPOL_MIXER (0x1 << 15) +#define M_SPKVOL_R_TO_SPOL_MIXER (0x1 << 14) +#define M_SPKVOL_L_TO_SPOR_MIXER (0x1 << 13) +#define M_SPKVOL_R_TO_SPOR_MIXER (0x1 << 12) +#define M_OUTVOL_L_TO_MONOMIXER (0x1 << 11) +#define M_OUTVOL_R_TO_MONOMIXER (0x1 << 10) + +/* Speaker/Mono/HP Output Control(0x2C) */ +#define SPK_L_MUX_SEL_MASK (0x3 << 14) +#define SPK_L_MUX_SEL_SPKMIXER_L (0x0 << 14) +#define SPK_L_MUX_SEL_MONO_IN (0x1 << 14) +#define SPK_L_MUX_SEL_DAC_L (0x3 << 14) + +#define SPK_R_MUX_SEL_MASK (0x3 << 10) +#define SPK_R_MUX_SEL_SPKMIXER_R (0x0 << 10) +#define SPK_R_MUX_SEL_MONO_IN (0x1 << 10) +#define SPK_R_MUX_SEL_DAC_R (0x3 << 10) + +#define MONO_MUX_SEL_MASK (0x3 << 6) +#define MONO_MUX_SEL_MONOMIXER (0x0 << 6) +#define MONO_MUX_SEL_MONO_IN (0x1 << 6) + +#define HP_L_MUX_SEL_MASK (0x1 << 3) +#define HP_L_MUX_SEL_HPVOL_L (0x0 << 3) +#define HP_L_MUX_SEL_DAC_L (0x1 << 3) + +#define HP_R_MUX_SEL_MASK (0x1 << 2) +#define HP_R_MUX_SEL_HPVOL_R (0x0 << 2) +#define HP_R_MUX_SEL_DAC_R (0x1 << 2) + +/* Stereo I2S Serial Data Port Control(0x34) */ +#define SDP_MODE_SEL_MASK (0x1 << 15) +#define SDP_MODE_SEL_MASTER (0x0 << 15) +#define SDP_MODE_SEL_SLAVE (0x1 << 15) + +#define SDP_ADC_CPS_SEL_MASK (0x3 << 10) +#define SDP_ADC_CPS_SEL_OFF (0x0 << 10) +#define SDP_ADC_CPS_SEL_U_LAW (0x1 << 10) +#define SDP_ADC_CPS_SEL_A_LAW (0x2 << 10) + +#define SDP_DAC_CPS_SEL_MASK (0x3 << 8) +#define SDP_DAC_CPS_SEL_OFF (0x0 << 8) +#define SDP_DAC_CPS_SEL_U_LAW (0x1 << 8) +#define SDP_DAC_CPS_SEL_A_LAW (0x2 << 8) +/* 0:Normal 1:Invert */ +#define SDP_I2S_BCLK_POL_CTRL (0x1 << 7) +/* 0:Normal 1:Invert */ +#define SDP_DAC_R_INV (0x1 << 6) +/* 0:ADC data appear at left phase of LRCK + * 1:ADC data appear at right phase of LRCK + */ +#define SDP_ADC_DATA_L_R_SWAP (0x1 << 5) +/* 0:DAC data appear at left phase of LRCK + * 1:DAC data appear at right phase of LRCK + */ +#define SDP_DAC_DATA_L_R_SWAP (0x1 << 4) + +/* Data Length Slection */ +#define SDP_I2S_DL_MASK (0x3 << 2) +#define SDP_I2S_DL_16 (0x0 << 2) +#define SDP_I2S_DL_20 (0x1 << 2) +#define SDP_I2S_DL_24 (0x2 << 2) +#define SDP_I2S_DL_8 (0x3 << 2) + +/* PCM Data Format Selection */ +#define SDP_I2S_DF_MASK (0x3) +#define SDP_I2S_DF_I2S (0x0) +#define SDP_I2S_DF_LEFT (0x1) +#define SDP_I2S_DF_PCM_A (0x2) +#define SDP_I2S_DF_PCM_B (0x3) + +/* Stereo AD/DA Clock Control(0x38h) */ +#define I2S_PRE_DIV_MASK (0x7 << 13) +#define I2S_PRE_DIV_1 (0x0 << 13) +#define I2S_PRE_DIV_2 (0x1 << 13) +#define I2S_PRE_DIV_4 (0x2 << 13) +#define I2S_PRE_DIV_8 (0x3 << 13) +#define I2S_PRE_DIV_16 (0x4 << 13) +#define I2S_PRE_DIV_32 (0x5 << 13) +/* CLOCK RELATIVE OF BCLK AND LCRK */ +#define I2S_LRCK_SEL_N_BCLK_MASK (0x1 << 12) +#define I2S_LRCK_SEL_64_BCLK (0x0 << 12) /* 64FS */ +#define I2S_LRCK_SEL_32_BCLK (0x1 << 12) /* 32FS */ + +#define DAC_OSR_SEL_MASK (0x3 << 10) +#define DAC_OSR_SEL_128FS (0x3 << 10) +#define DAC_OSR_SEL_64FS (0x3 << 10) +#define DAC_OSR_SEL_32FS (0x3 << 10) +#define DAC_OSR_SEL_16FS (0x3 << 10) + +#define ADC_OSR_SEL_MASK (0x3 << 8) +#define ADC_OSR_SEL_128FS (0x3 << 8) +#define ADC_OSR_SEL_64FS (0x3 << 8) +#define ADC_OSR_SEL_32FS (0x3 << 8) +#define ADC_OSR_SEL_16FS (0x3 << 8) + +#define ADDA_FILTER_CLK_SEL_256FS (0 << 7) /* 256FS */ +#define ADDA_FILTER_CLK_SEL_384FS (1 << 7) /* 384FS */ + +/* Power managment addition 1 (0x3A) */ +#define PWR_MAIN_I2S_EN (0x1 << 15) +#define PWR_CLASS_D (0x1 << 12) +#define PWR_ADC_L_CLK (0x1 << 11) +#define PWR_ADC_R_CLK (0x1 << 10) +#define PWR_DAC_L_CLK (0x1 << 9) +#define PWR_DAC_R_CLK (0x1 << 8) +#define PWR_DAC_REF (0x1 << 7) +#define PWR_DAC_L_TO_MIXER (0x1 << 6) +#define PWR_DAC_R_TO_MIXER (0x1 << 5) + +/* Power managment addition 2 (0x3B) */ +#define PWR_OUTMIXER_L (0x1 << 15) +#define PWR_OUTMIXER_R (0x1 << 14) +#define PWR_SPKMIXER_L (0x1 << 13) +#define PWR_SPKMIXER_R (0x1 << 12) +#define PWR_RECMIXER_L (0x1 << 11) +#define PWR_RECMIXER_R (0x1 << 10) +#define PWR_MIC1_BOOT_GAIN (0x1 << 5) +#define PWR_MIC2_BOOT_GAIN (0x1 << 4) +#define PWR_MICBIAS1_VOL (0x1 << 3) +#define PWR_MICBIAS2_VOL (0x1 << 2) +#define PWR_PLL (0x1 << 1) + +/* Power managment addition 3(0x3C) */ +#define PWR_VREF (0x1 << 15) +#define PWR_FAST_VREF_CTRL (0x1 << 14) +#define PWR_MAIN_BIAS (0x1 << 13) +#define PWR_AXO1MIXER (0x1 << 11) +#define PWR_AXO2MIXER (0x1 << 10) +#define PWR_MONOMIXER (0x1 << 9) +#define PWR_MONO_DEPOP_DIS (0x1 << 8) +#define PWR_MONO_AMP_EN (0x1 << 7) +#define PWR_CHARGE_PUMP (0x1 << 4) +#define PWR_HP_L_AMP (0x1 << 3) +#define PWR_HP_R_AMP (0x1 << 2) +#define PWR_HP_DEPOP_DIS (0x1 << 1) +#define PWR_HP_AMP_DRIVING (0x1) + +/* Power managment addition 4(0x3E) */ +#define PWR_SPK_L_VOL (0x1 << 15) +#define PWR_SPK_R_VOL (0x1 << 14) +#define PWR_LOUT_VOL (0x1 << 13) +#define PWR_ROUT_VOL (0x1 << 12) +#define PWR_HP_L_OUT_VOL (0x1 << 11) +#define PWR_HP_R_OUT_VOL (0x1 << 10) +#define PWR_AXIL_IN_VOL (0x1 << 9) +#define PWR_AXIR_IN_VOL (0x1 << 8) +#define PWR_MONO_IN_P_VOL (0x1 << 7) +#define PWR_MONO_IN_N_VOL (0x1 << 6) + +/* General Purpose Control Register(0x40) */ +#define SPK_AMP_AUTO_RATIO_EN (0x1 << 15) + +#define SPK_AMP_RATIO_CTRL_MASK (0x7 << 12) +#define SPK_AMP_RATIO_CTRL_2_34 (0x0 << 12) /* 7.40DB */ +#define SPK_AMP_RATIO_CTRL_1_99 (0x1 << 12) /* 5.99DB */ +#define SPK_AMP_RATIO_CTRL_1_68 (0x2 << 12) /* 4.50DB */ +#define SPK_AMP_RATIO_CTRL_1_56 (0x3 << 12) /* 3.86DB */ +#define SPK_AMP_RATIO_CTRL_1_44 (0x4 << 12) /* 3.16DB */ +#define SPK_AMP_RATIO_CTRL_1_27 (0x5 << 12) /* 2.10DB */ +#define SPK_AMP_RATIO_CTRL_1_09 (0x6 << 12) /* 0.80DB */ +#define SPK_AMP_RATIO_CTRL_1_00 (0x7 << 12) /* 0.00DB */ + +#define STEREO_DAC_HI_PASS_FILT_EN (0x1 << 11) +#define STEREO_ADC_HI_PASS_FILT_EN (0x1 << 10) +/* Select ADC Wind Filter Clock type */ +#define ADC_WIND_FILT_MASK (0x3 << 4) +#define ADC_WIND_FILT_8_16_32K (0x0 << 4) /* 8/16/32k */ +#define ADC_WIND_FILT_11_22_44K (0x1 << 4) /* 11/22/44k */ +#define ADC_WIND_FILT_12_24_48K (0x2 << 4) /* 12/24/48k */ +#define ADC_WIND_FILT_EN (0x1 << 3) +/* SelectADC Wind Filter Corner Frequency */ +#define ADC_WIND_CNR_FREQ_MASK (0x7 << 0) +#define ADC_WIND_CNR_FREQ_82_113_122 (0x0 << 0) /* 82/113/122 Hz */ +#define ADC_WIND_CNR_FREQ_102_141_153 (0x1 << 0) /* 102/141/153 Hz */ +#define ADC_WIND_CNR_FREQ_131_180_156 (0x2 << 0) /* 131/180/156 Hz */ +#define ADC_WIND_CNR_FREQ_163_225_245 (0x3 << 0) /* 163/225/245 Hz */ +#define ADC_WIND_CNR_FREQ_204_281_306 (0x4 << 0) /* 204/281/306 Hz */ +#define ADC_WIND_CNR_FREQ_261_360_392 (0x5 << 0) /* 261/360/392 Hz */ +#define ADC_WIND_CNR_FREQ_327_450_490 (0x6 << 0) /* 327/450/490 Hz */ +#define ADC_WIND_CNR_FREQ_408_563_612 (0x7 << 0) /* 408/563/612 Hz */ + +/* Global Clock Control Register(0x42) */ +#define SYSCLK_SOUR_SEL_MASK (0x1 << 14) +#define SYSCLK_SOUR_SEL_MCLK (0x0 << 14) +#define SYSCLK_SOUR_SEL_PLL (0x1 << 14) +#define SYSCLK_SOUR_SEL_PLL_TCK (0x2 << 14) + +#define PLLCLK_SOUR_SEL_MCLK (0x0 << 12) +#define PLLCLK_SOUR_SEL_BITCLK (0x1 << 12) + +#define PLLCLK_PRE_DIV1 (0x0 << 11) +#define PLLCLK_PRE_DIV2 (0x1 << 11) + +/* 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_FUN_SEL_MASK (0x1 << 15) +#define GPIO_PIN_FUN_SEL_IRQ (0x1 << 15) +#define GPIO_PIN_FUN_SEL_GPIO_DIMC (0x0 << 15) + +#define GPIO_DMIC_FUN_SEL_MASK (0x1 << 3) +#define GPIO_DMIC_FUN_SEL_DIMC (0x1 << 3) /* GPIO pin SELECT DMIC */ +#define GPIO_DMIC_FUN_SEL_GPIO (0x0 << 3) /* GPIO PIN SELECT GPIO */ + +#define GPIO_PIN_CON_MASK (0x1 << 2) +#define GPIO_PIN_SET_INPUT (0x0 << 2) +#define GPIO_PIN_SET_OUTPUT (0x1 << 2) + +/* De-POP function Control 1(0x54) */ +#define POW_ON_SOFT_GEN (0x1 << 15) +#define EN_MUTE_UNMUTE_DEPOP (0x1 << 14) +#define EN_DEPOP2_FOR_HP (0x1 << 7) +/* Power Down HPAMP_L Starts Up Signal */ +#define PD_HPAMP_L_ST_UP (0x1 << 5) +/* Power Down HPAMP_R Starts Up Signal */ +#define PD_HPAMP_R_ST_UP (0x1 << 4) +/* Enable left HP mute/unmute depop */ +#define EN_HP_L_M_UN_MUTE_DEPOP (0x1 << 1) +/* Enable right HP mute/unmute depop */ +#define EN_HP_R_M_UN_MUTE_DEPOP (0x1 << 0) + +/* De-POP Fnction Control(0x56) */ +#define EN_ONE_BIT_DEPOP (0x1 << 15) +#define EN_CAP_FREE_DEPOP (0x1 << 14) + +/* Jack Detect Control Register(0x5A) */ +#define JD_USE_MASK (0x3 << 14) +#define JD_USE_JD2 (0x3 << 14) +#define JD_USE_JD1 (0x2 << 14) +#define JD_USE_GPIO (0x1 << 14) +#define JD_OFF (0x0 << 14) +/* JD trigger enable for HP */ +#define JD_HP_EN (0x1 << 11) +#define JD_HP_TRI_MASK (0x1 << 10) +#define JD_HP_TRI_HI (0x1 << 10) +#define JD_HP_TRI_LO (0x1 << 10) +/* JD trigger enable for speaker LP/LN */ +#define JD_SPK_L_EN (0x1 << 9) +#define JD_SPK_L_TRI_MASK (0x1 << 8) +#define JD_SPK_L_TRI_HI (0x1 << 8) +#define JD_SPK_L_TRI_LO (0x0 << 8) +/* JD trigger enable for speaker RP/RN */ +#define JD_SPK_R_EN (0x1 << 7) +#define JD_SPK_R_TRI_MASK (0x1 << 6) +#define JD_SPK_R_TRI_HI (0x1 << 6) +#define JD_SPK_R_TRI_LO (0x0 << 6) +/* JD trigger enable for monoout */ +#define JD_MONO_EN (0x1 << 5) +#define JD_MONO_TRI_MASK (0x1 << 4) +#define JD_MONO_TRI_HI (0x1 << 4) +#define JD_MONO_TRI_LO (0x0 << 4) +/* JD trigger enable for Lout */ +#define JD_AUX_1_EN (0x1 << 3) +#define JD_AUX_1_MASK (0x1 << 2) +#define JD_AUX_1_TRI_HI (0x1 << 2) +#define JD_AUX_1_TRI_LO (0x0 << 2) +/* JD trigger enable for Rout */ +#define JD_AUX_2_EN (0x1 << 1) +#define JD_AUX_2_MASK (0x1 << 0) +#define JD_AUX_2_TRI_HI (0x1 << 0) +#define JD_AUX_2_TRI_LO (0x0 << 0) + +/* ALC CONTROL 1(0x64) */ +#define ALC_ATTACK_RATE_MASK (0x1F << 8) +#define ALC_RECOVERY_RATE_MASK (0x1F << 0) + +/* ALC CONTROL 2(0x65) */ +/* select Compensation gain for Noise gate function */ +#define ALC_COM_NOISE_GATE_MASK (0xF << 0) + +/* ALC CONTROL 3(0x66) */ +#define ALC_FUN_MASK (0x3 << 14) +#define ALC_FUN_DIS (0x0 << 14) +#define ALC_ENA_DAC_PATH (0x1 << 14) +#define ALC_ENA_ADC_PATH (0x3 << 14) +#define ALC_PARA_UPDATE (0x1 << 13) +#define ALC_LIMIT_LEVEL_MASK (0x1F << 8) +#define ALC_NOISE_GATE_FUN_MASK (0x1 << 7) +#define ALC_NOISE_GATE_FUN_DIS (0x0 << 7) +#define ALC_NOISE_GATE_FUN_ENA (0x1 << 7) +/* ALC noise gate hold data function */ +#define ALC_NOISE_GATE_H_D_MASK (0x1 << 6) +#define ALC_NOISE_GATE_H_D_DIS (0x0 << 6) +#define ALC_NOISE_GATE_H_D_ENA (0x1 << 6) + +/* Psedueo Stereo & Spatial Effect Block Control(0x68) */ +#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) +/* 3D gain parameter */ +#define GAIN_3D_PARA_MASK (0x3 << 6) +#define GAIN_3D_PARA_1_00 (0x0 << 6) /* 3D gain 1.0 */ +#define GAIN_3D_PARA_1_50 (0x1 << 6) /* 3D gain 1.5 */ +#define GAIN_3D_PARA_2_00 (0x2 << 6) /* 3D gain 2.0 */ +/* 3D ratio parameter */ +#define RATIO_3D_MASK (0x3 << 4) +#define RATIO_3D_0_0 (0x0 << 4) /* 3D ratio 0.0 */ +#define RATIO_3D_0_66 (0x1 << 4) /* 3D ratio 0.66 */ +#define RATIO_3D_1_0 (0x2 << 4) /* 3D ratio 1.0 */ +/* select samplerate for all pass filter */ +#define APF_FUN_SLE_MASK (0x3 << 0) +#define APF_FUN_SEL_48K (0x3 << 0) +#define APF_FUN_SEL_44_1K (0x2 << 0) +#define APF_FUN_SEL_32K (0x1 << 0) +#define APF_FUN_DIS (0x0 << 0) + +/* EQ CONTROL 1(0x6E) */ +#define HW_EQ_PATH_SEL_MASK (0x1 << 15) +#define HW_EQ_PATH_SEL_DAC (0x0 << 15) +#define HW_EQ_PATH_SEL_ADC (0x1 << 15) +#define HW_EQ_UPDATE_CTRL (0x1 << 14) + +#define EN_HW_EQ_HPF2 (0x1 << 5) +#define EN_HW_EQ_HPF1 (0x1 << 4) +#define EN_HW_EQ_BP3 (0x1 << 3) +#define EN_HW_EQ_BP2 (0x1 << 2) +#define EN_HW_EQ_BP1 (0x1 << 1) +#define EN_HW_EQ_LPF (0x1 << 0) + +#endif /* __RTCODEC5631_H__ */ diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index d7170f1381aa..89bbc7dd242e 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -25,10 +25,23 @@ #include #include #include +#include #include +#include +#include + #include "wm8988.h" +#include +#include + +#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, diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 83014a7c2e14..8da1cc17b79c 100755 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -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 #include #include @@ -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, diff --git a/sound/soc/rk29/Kconfig b/sound/soc/rk29/Kconfig index 2f1829bfbf69..9474a30ea572 100755 --- a/sound/soc/rk29/Kconfig +++ b/sound/soc/rk29/Kconfig @@ -52,22 +52,22 @@ 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. -config SND_RK29_SOC_alc5631 - tristate "SoC I2S Audio support for rockchip - alc5631" + with the rt5621. +config SND_RK29_SOC_RT5631 + tristate "SoC I2S Audio support for rockchip - RT5631" depends on SND_RK29_SOC && I2C_RK29 select SND_RK29_SOC_I2S - select SND_SOC_alc5631 + select SND_SOC_RT5631 help Say Y if you want to add support for SoC audio on rockchip - with the alc5631. + with the RT5631. config SND_RK29_SOC_RT5625 tristate "SoC I2S Audio support for rockchip - RT5625" @@ -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_alc5631 || 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 diff --git a/sound/soc/rk29/Makefile b/sound/soc/rk29/Makefile index f10294f7f32a..cc0c09b0b40d 100644 --- a/sound/soc/rk29/Makefile +++ b/sound/soc/rk29/Makefile @@ -7,8 +7,8 @@ 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-alc5631-objs := rk29_rt5631.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 snd-soc-wm8988-objs := rk29_wm8988.o @@ -18,8 +18,8 @@ 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_alc5631) += snd-soc-alc5631.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 obj-$(CONFIG_SND_RK29_SOC_CS42L52) += snd-soc-cs42l52.o diff --git a/sound/soc/rk29/rk29_alc5621.c b/sound/soc/rk29/rk29_alc5621.c deleted file mode 100644 index 62f2ed545d05..000000000000 --- a/sound/soc/rk29/rk29_alc5621.c +++ /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 -#include -#include -#include -#include -#include -#include -#include -#include -#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"); diff --git a/sound/soc/rk29/rk29_pcm.c b/sound/soc/rk29/rk29_pcm.c index 689a9910f71e..a2cb3e96a8dc 100755 --- a/sound/soc/rk29/rk29_pcm.c +++ b/sound/soc/rk29/rk29_pcm.c @@ -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 index 000000000000..dca3e849a3bc --- /dev/null +++ b/sound/soc/rk29/rk29_rt5621.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#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"); diff --git a/sound/soc/rk29/rk29_rt5631.c b/sound/soc/rk29/rk29_rt5631.c index 0b93043bda4c..a83f5a9920fe 100644 --- a/sound/soc/rk29/rk29_rt5631.c +++ b/sound/soc/rk29/rk29_rt5631.c @@ -34,19 +34,18 @@ 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_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->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 @@ -164,28 +163,28 @@ static const struct snd_soc_dapm_route audio_map[]={ /* * Logic for a rt5631 as connected on a rockchip board. */ -static int rk29_rt5631_init(struct snd_soc_codec *codec) +static int rk29_rt5631_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_dai *codec_dai = &codec->dai[0]; - int ret; - + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dapm_context *dapm = &codec->dapm; + DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); /* Add specific widgets */ - snd_soc_dapm_new_controls(codec, rt5631_dapm_widgets, + snd_soc_dapm_new_controls(dapm, rt5631_dapm_widgets, ARRAY_SIZE(rt5631_dapm_widgets)); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); /* 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)); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); -// snd_soc_dapm_nc_pin(codec, "HP_L"); + snd_soc_dapm_nc_pin(dapm, "HP_L"); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); -// snd_soc_dapm_nc_pin(codec, "HP_R"); + snd_soc_dapm_nc_pin(dapm, "HP_R"); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - snd_soc_dapm_sync(codec); + snd_soc_dapm_sync(dapm); DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__); - return 0; + return 0; } static struct snd_soc_ops rk29_ops = { @@ -193,44 +192,39 @@ static struct snd_soc_ops rk29_ops = { }; static struct snd_soc_dai_link rk29_dai = { - .name = "RT5631", - .stream_name = "RT5631 PCM", - .cpu_dai = &rk29_i2s_dai[0], - .codec_dai = &rt5631_dai, - .init = rk29_rt5631_init, - .ops = &rk29_ops, + .name = "RT5631", + .stream_name = "RT5631 PCM", + .codec_name = "RT5631.0-001a", + .platform_name = "rockchip-audio", + .cpu_dai_name = "rk29_i2s.0", + .codec_dai_name = "RT5631 HiFi", + .init = rk29_rt5631_init, + .ops = &rk29_ops, }; static struct snd_soc_card snd_soc_card_rk29 = { - .name = "RK29_RT5631", - .platform = &rk29_soc_platform, - .dai_link = &rk29_dai, - .num_links = 1, -}; - - -static struct snd_soc_device rk29_snd_devdata = { - .card = &snd_soc_card_rk29, - .codec_dev = &soc_codec_dev_rt5631, + .name = "RK29_RT5631", + .dai_link = &rk29_dai, + .num_links = 1, }; static struct platform_device *rk29_snd_device; static int __init audio_card_init(void) { - int ret =0; + 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"); + printk("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"); + printk("platform device add failed\n"); platform_device_put(rk29_snd_device); } return ret; diff --git a/sound/soc/rk29/rk29_wm8988.c b/sound/soc/rk29/rk29_wm8988.c index 29c4a709ab84..e9abd89e43b5 100755 --- a/sound/soc/rk29/rk29_wm8988.c +++ b/sound/soc/rk29/rk29_wm8988.c @@ -1,5 +1,5 @@ /* - * rk2818_wm8988.c -- SoC audio for rockchip + * rk29_wm8988.c -- SoC audio for rockchip * * Driver for rockchip wm8988 audio * @@ -24,18 +24,22 @@ #include "rk29_pcm.h" #include "rk29_i2s.h" +#include + #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); diff --git a/sound/soc/rk29/rk29_wm8994.c b/sound/soc/rk29/rk29_wm8994.c index b666b0c20906..84222e918eef 100755 --- a/sound/soc/rk29/rk29_wm8994.c +++ b/sound/soc/rk29/rk29_wm8994.c @@ -26,79 +26,95 @@ #include "rk29_i2s.h" #include -#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,8 +129,8 @@ 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); @@ -122,12 +138,165 @@ static int rk29_hw_params(struct snd_pcm_substream *substream, 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)); + snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, pll_out, 0); #endif - return 0; + 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); +#endif + + 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_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_card snd_soc_card_rk29 = { - .name = "RK29_WM8994", - .platform = &rk29_soc_platform, - .dai_link = &rk29_dai, - .num_links = 1, -}; - - -static struct snd_soc_device rk29_snd_devdata = { - .card = &snd_soc_card_rk29, - .codec_dev = &soc_codec_dev_wm8994, + .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)